Heim >Backend-Entwicklung >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
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 "
userid | name | pssword | maxsmscount | maxuseday | leftday | leftsmscount |
$row[0] | $row[1] | $row[2] | $row[3] | $row[4] | $row[5] | $row[6] |