参见英文答案 >
Warning: mysql_fetch_* expects parameter 1 to be resource, boolean given error 我正在尝试设置我的数据库但是我遗憾地遇到了一些问题.我已经看到很多人问过相同或类似的问题,但无论我如何看待我的代码,并修改它.我更加困惑,并添加更多错误.所以,如果有人能向我解释我如何尝试修复它,我会很感激.
这是错误消息:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/folder/public_html/folder/folder/login.php on line 18
这是代码:
$filename = 'install.php';
if (file_exists($filename)) {
echo ("
After installing please delete install.php
} else {
if (isset($_POST['Login'])){
include('config.php');
if (!mysql_connect($host, $username, $password)) die("Can't connect to database");
if (!mysql_select_db($db_name)) die("Can't select database");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count >= 1){
session_register("myusername");
session_register("mypassword");
header("location: index.php");
} else {
echo "
}
}
?>
Username
Password
}
?>
这是第18行
$count=mysql_num_rows($result);