使用mysql_fetch_array()的时候出现这行警告,没有返回任何记录
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\php\PHPnow-1.5.6\htdocs\default.php on line 26不仅仅是这个函数mysql_fetch_array()不能用,使用mysql_num_rows()函数也会出现同样的警告
怎么解决呢?
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\php\PHPnow-1.5.6\htdocs\default.php on line 26不仅仅是这个函数mysql_fetch_array()不能用,使用mysql_num_rows()函数也会出现同样的警告
怎么解决呢?
是这样的
//include "MySQL.php";
$my_sql_name="localhost";
$my_username="root";
$my_password="admin";
$my_database="pet";
$conn = mysql_connect($my_sql_name,$my_username,$my_password,$my_database);
if (!$conn)
{
die('Could not connect: ' . mysql_error());
mysql_close();
}
$sql="select * from pet";
//mysql_select_db("pet",$conn);
$result = mysql_query($sql,$conn);
while($row = mysql_fetch_array($result))
{
$row['owner']."<Br />";
}
?>