MySQL查询无法在连接成功时返回数据

时间:2019-04-01 11:25:00

标签: php mysql mysqli

我是MySQL的新手,我正面临使mysqli查询正常工作的困难。我可以连接到数据库并在开发机器上查询所有内容都可以正常工作,但查询在Capnel上不返回任何数据。我已经阅读了有关此问题的相关文章,但似乎都无法解决该问题。我真的很想知道这是否是托管缺陷,PHP版本错误或我的代码。下面是我的数据库连接和查询。

<?php
define("DB_SERVER", "localhost");
define("DB_USER", "myuser");
define("DB_PASSWORD", "mypassword");
define("DB_DATABASE", "mydatabase");

$conn = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE);
?>


$email = mysqli_real_escape_string($conn, $_POST['email']);           
$password = mysqli_real_escape_string($conn, $_POST['password']);

$sql = "SELECT * FROM 'sbausers' WHERE email = '$email' AND Password = '$password'";
$stmt = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($stmt);
if ($row > 0){
    echo 'it works';
} else {
    echo 'it doesn't work';
}

0 个答案:

没有答案