可能重复:
警告:mysql_fetch_array() 期望参数 1 是资源,布尔值在 problema con el wile 中给出
当我执行 login form 时,我会遇到以下错误:
警告:mysql_fetch_assoc() 期望参数 1 是资源,布尔值在第 22 行的 C:\xampp\htdocs\login\check.php 中给出
<?php
include_once ("function.php");
$username = $_POST['tfuser'] ;
$password = $_POST['tfpass'] ;
if (isset($username) && isset($password)){
$link = mysql_connect('localhost','root','') or die ('error in connecting to db');
mysql_select_db('login',$link) or die ('error select db');
$sql = "select from * from administration
where username='$username' and password='$password'";
$result = mysql_query($sql,$link);
if (mysql_fetch_assoc($result)){
//login to panel
redirect("panel.php");
} else {
//back to login page
}
} else {
//back to login page
redirect("index.php");
}
?>
现在如何防止此错误显示并防止 Mysql_fetch_assoc 错误?