mysql_fetch_row
function db_connect()
{
$result = new mysqli('localhost', 'root', '654321', 'smsprj');
//$result = new mysqli('localhost', 'root', '654321');
if (!$result)
{
throw new Exception('Could not connect to database server');
}
else
{
return $result;
}
}
?>
$conn = db_connect();
$sql = $conn->query("SELECT * FROM user");
if (!$sql)
{
echo ("wrong");
}
else
{
echo "
";
echo "
userid |
name |
pssword |
maxsmscount |
maxuseday |
leftday |
leftsmscount |
";
while( $row = mysql_fetch_row($sql) )
{
echo "
$row[0] |
$row[1] |
$row[2] |
$row[3] |
$row[4] |
$row[5] |
$row[6] |
";
}
}
我的目的是将数据库中的所有用户信息显示出来
可这段程序老是报错,不知道什么原因
求大侠帮助,小弟不胜感激
回复讨论(解决方案)
db_connect 中是这样的
$result = new mysqli('localhost', 'root', '654321', 'smsprj');
所以要这样查询
$sql = $conn->query("SELECT * FROM user");
要这样读取
while( $row = $sql->fetch_row())
非常感谢,明天去公司试试。
被安排了根本不会的工作,真的是很让人蛋疼啊
非常感谢,明天去公司试试。
被安排了根本不会的工作,真的是很让人蛋疼啊
非常感谢,明天去公司试试。
被安排了根本不会的工作,真的是很让人蛋疼啊
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn