连接到数据库时出现PHP错误

时间:2017-02-25 13:36:38

标签: php database

当我尝试在localhost中运行我的php文件时,我一直收到以下错误。谁能告诉我这是什么问题?我的代码如下。感谢

<?PHP
    require "conn.php";
    $password = "John123";
    $email = "John@lally.com";
    $mysql_qry = "select * from hospital where password like '$password' and email like '$email';";
    $result = mysqli_query($conn ,$mysql_qry);
    if(mysqli_num_rows($result) > 0){
        echo "Login success";
    }
    else{
        echo "Login not successful";
    }
?>

SQL error

这是conn.php的代码:

<?php
    $db_name = "hospital";
    $mysql_username = "root";
    $mysql_password = "";
    $server_name = "localhost";
    $conn = mysqli_connect($server_name, $mysql_username, $mysql_password, $db_name);
    if($conn){
         echo "Connection success";
    }
    else{
         echo "Connection not successful";
    }
 ?>

0 个答案:

没有答案