Bluehost MySQLi配置问题

时间:2013-04-17 18:53:01

标签: php mysql database mysqli

我有以下脚本,它在我的本地机器上完美运行(XAMPP v3.1.0 php v.5.4.7),但是当我上传到我的网络服务器(Bluehost php v5.4.13)时,它无效。< / p>

我的桌子很好&amp;我给它的数据是有效的。

// Connect to DB
$mysqli = new mysqli("localhost","{USER_NAME}","{PASSWORD}","{TABLE_NAME}");
// Escaped post variables before SQL lookup
    // $email is valid -  "john@john.com";
$escapedEmail = $mysqli->real_escape_string($email);
$retrievedPassword = "";
$getUserPasswordQuery = "Select * FROM User Where Email='{$escapedEmail}'";
$loggedInUser = null;


if ($getUserPasswordResult = $mysqli->query($getUserPasswordQuery);)
{
    echo "GOT HERE";
    // Query was successful
}
$getUserPasswordResult->free(); // Line 66 (See below)

获取echo语句但我在日志中获取以下内容(如果查询不起作用,则可以理解)。

Call to a member function free() on a non-object in .../script.php on line 66

任何人都可以对这个&amp;也许为什么它在localserver&amp;不是在野外。另外,我是以正确的方式做到这一点还是有更加防弹的范例?

谢谢!

1 个答案:

答案 0 :(得分:0)

您在测试之外调用free以查看是否正确定义了该变量:

if ($getUserPasswordResult = $mysqli->query($getUserPasswordQuery);)
{
    echo "GOT HERE";
    // Query was successful
    $getUserPasswordResult->free(); // Line 66 (See below)
}