php代码中的错误:尝试验证记录是否存在

时间:2017-03-15 17:16:33

标签: php html mysql mysqli

我试图检查特定的rno是否存在于任何特定的表角色中。 rno和role都是从html格式获取的。有人可以帮忙吗?

   <?php

 $rno=$_POST['rno'];
 $role=$_POST['role'];

$con = new  mysqli("localhost", "root", "", "premierlg");

if ($con->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$query = mysqli_query($con, "SELECT * FROM" .$rno. " WHERE rno='".$rno."'");

if(mysqli_num_rows($query) > 0){

    echo "Record already exists";
}else{
    echo "Dosen't exist.";
if (!mysqli_query($con,$query))
    {
        die('Error: ' . mysqli_error($con));
    }
}

?>

0 个答案:

没有答案