Home > Backend Development > PHP Tutorial > :mysql_fetch_row(): supplied argument is not a valid MySQL result resource

:mysql_fetch_row(): supplied argument is not a valid MySQL result resource

WBOY
Release: 2016-06-13 12:47:18
Original
1081 people have browsed it

求救:mysql_fetch_row(): supplied argument is not a valid MySQL result resource

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 "";
while( $row = mysql_fetch_row($sql) )
{
echo "";
}
}
我的目的是将数据库中的所有用户信息显示出来
可这段程序老是报错,不知道什么原因
求大侠帮助,小弟不胜感激
mysql_fetch_row
userid name pssword maxsmscount maxuseday leftday leftsmscount
$row[0] $row[1] $row[2] $row[3] $row[4] $row[5] $row[6]
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template