可能重复:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
当我尝试将MySQL记录集作为对象获取时,我收到以下警告:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in/home/bbbbb/public_html/curl.php on line 24
我该如何解决这个问题?
这是脚本:
<?php
$mysqlhost="....."; // Host name
$mysqluser="...."; // Mysql username
$mysqlpasswd="....."; // Mysql password
$mysqldbname="......"; // Database name
//$post_item[]='username='.$_POST['username'];
$username=$_POST['username'];
$con = @mysql_pconnect($mysqlhost, $mysqluser, $mysqlpasswd);
if(!$con) {
echo "Mysql error: " . mysql_error();
exit();
}
mysql_select_db($mysqldbname);
$mysqlt = "dle_users"; ///Your table////
$abfrage = "SELECT * FROM `$mysqlt`";
$ergebnis = mysql_query($abfrage);
$tb = array();
while($row = mysql_fetch_object($ergebnis))
{
$tb[] = $row->username;
}
if (!in_array($username, $tb)) {
return false;
echo "Wrong Username or Password";
}
else {
echo "Login Successful";
return true;
}
?>
答案 0 :(得分:1)
尝试:
...
$ergebnis = mysql_query($abfrage);
if (false === $ergebnis){
echo mysql_error();
exit;
}
...
显示结果。