我试图从数据库中获取值,但它显示“mysql_fetch_array() 期望参数 1 是资源,在第 15 行的 C:\wamp\www\kcms\a.php 中给出的布尔值”错误。有人能帮我吗?
<?php
//include 'functions.php';
$con = mysql_connect("localhost","Akash","kaka123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$student = false;
$teacher = false;
$office = false;
$username = 56;
$password = 38;
$query= "SELECT Register_no , Password FROM student profile WHERE Register_no=$username AND Password=$password" ;
$result = mysql_query($query, $con);
$prnt=mysql_fetch_array($result);
if ($prnt[0]==NULL)
{
$auth=0;
}
else
{
$auth=1;
$student= true;
}
if ($auth==0)
{
$query= "SELECT Staff_id , Password FROM staff profile WHERE Staff_id=$username AND Password=$password" ;
$result = mysql_query($query, $con);
$prnt=mysql_fetch_array($result);
if ($prnt[0]=NULL)
{
$auth=0;
}
else
{
$auth=1;
$teacher = true;
}
}
if ($auth==0)
{
$query= "SELECT Staff_id , Password FROM office staff WHERE Staff_id=$username AND Password=$password" ;
$result = mysql_query($query, $con);
$prnt=mysql_fetch_array($result);
if ($prnt[0]==NULL)
{
$auth=0;
}
else
{
$auth=1;
$office = true;
}
}
echo $username;
?>
有人可以尽快回复吗?