我遇到这些错误:
警告:mysql_query()期望参数1是字符串,第12行的H:\ xamp \ htdocs \ newlogintry.php中给出的对象
警告:mysql_query()期望参数1为字符串,在第13行的H:\ xamp \ htdocs \ newlogintry.php中给出的对象
警告:mysqli_num_rows()期望参数1为mysqli_result,第18行的H:\ xamp \ htdocs \ newlogintry.php中给定的null
但是这是我为此编写的php代码,我想检查帐户的“类型”是教师帐户还是学生帐户(如果其中有的话),然后使用各自的类型参数传递到主页,请告诉如果我对php的用法是正确的,因为我对它不熟悉,这是php代码(newlogintry.php)
<?php
$start=1;
$username=$_GET['username'];
$password=$_GET['password'];
$con=mysqli_connect("localhost","root","","repute system");
if(mysqli_connect_errno()){
echo "ERROR ".mysqli_connect_error();
}
//$result = mysqli_query($con,"SELECT password FROM accounts WHERE username=".$username);
$result = mysqli_query($con,"SELECT password,username,type,u_name FROM accounts ");
$new = mysql_query($con, "SELECT name,USN,repute,acc_type,u_name FROM pupil ");
$new1= mysql_query($con,"SELECT name,id,repute,acc_type,u_name FROM teacher");
if(mysqli_num_rows($new)>0)
{
while($row = mysqli_fetch_assoc($new)) {
$pupilaccount = $row['acc_type'];
if(mysqli_num_rows($new1)>0)
{
while($row = mysqli_fetch_assoc($new1)) {
$teacheraccount = $row['acc_type'];
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_assoc($result)) {
$pass=$row['password'];
$use=$row['username'];
$type=$row['type'];
if( $type==$teacheraccount and $password == $pass and $username==$use){
header("location:http://localhost/index.php?param=$teacheraccount¶m1=$username");
exit();
}
else if($type==$pupilaccount and $password == $pass and $username==$use)
{
header("location:http://localhost/index.php?param==$pupilaccount¶m1=$username");
exit();
}
}
}
}
}
}
}
}
?>
错误消息: