mysql_fetch_array错误localhost

时间:2015-05-14 15:00:19

标签: php mysql

我在XAMPP上使用PHP门户。当我尝试登录时,我得到了这个错误:

警告:mysql_fetch_array()要求参数1为资源,在第20行的C:\ xampp \ htdocs \ JOBPORTAL \ login.php中给出布尔值

警告:mysql_num_rows()要求参数1为资源,第21行的C:\ xampp \ htdocs \ JOBPORTAL \ login.php中给出布尔值

这是代码:

  <?php
session_start();
$UserName=$_POST['txtUser'];
$Password=$_POST['txtPass'];
$UserType=$_POST['cmbUser'];
if($UserType=="Administrator")
{
$con = mysql_connect("localhost","");
mysql_select_db("jobs", $con);
$sql = "select * from user_master where UserName='".$UserName."' and Password='".$Password."'";
$result = mysql_query($sql,$con);
$records = mysql_num_rows($result);
$row = mysql_fetch_array($result);
if ($records==0)
{
echo '<script type="text/javascript">alert("Wrong UserName or Password");window.location=\'index.php\';</script>';
}
else
{
header("location:Admin/index.php");
} 
mysql_close($con);
}
else if($UserType=="JobSeeker")
{
$con = mysql_connect("localhost","");
mysql_select_db("jobs", $con);
$sql = "select * from jobseeker_reg where UserName='".$UserName."' and Password='".$Password."' and Status='Confirm'";
$result = mysql_query($sql,$con);
$records = mysql_num_rows($result);
$row = mysql_fetch_array($result);
if ($records==0)
{
echo '<script type="text/javascript">alert("Wrong UserName or Password");window.location=\'index.php\';</script>';
}
else
{
$_SESSION['ID']=$row['JobSeekId'];
$_SESSION['Name']=$row['JobSeekerName'];
header("location:JobSeeker/index.php");
} 
mysql_close($con);
}
else
{
$con = mysql_connect("localhost","");
mysql_select_db("jobs", $con);
$sql = "select * from employer_reg where UserName='".$UserName."' and Password='".$Password."' and Status='Confirm'";
$result = mysql_query($sql,$con);
$records = mysql_num_rows($result);
$row = mysql_fetch_array($result);
if ($records==0)
{
echo '<script type="text/javascript">alert("Wrong UserName or Password");window.location=\'index.php\';</script>';
}
else
{
$_SESSION['ID']=$row['EmployerId'];
$_SESSION['Name']=$row['CompanyName'];
header("location:Employer/index.php");
} 
mysql_close($con);
}
?>

</body>
</html>

0 个答案:

没有答案