如何解决:致命错误:调用成员函数real_escape_string()

时间:2017-06-28 18:21:16

标签: php mysql mysqli

致命错误:在第41行的/home/vlindr.com/public_html/functions.php中调用boolean上的成员函数real_escape_string()

我刚刚上传了我的网站,并尝试登录但是出现了错误,

这里的代码应该有错误...

$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if ($connection->connect_error) {
    die($connection->connect_error);
}

function createTable($name, $query)
{
    queryMysql("CREATE TABLE IF NOT EXISTS $name($query)");
    echo "Table '$name' created or already exists.";
}

function queryMysql($query)
{
    global $connection;
    $result = $connection->query($query);
    if (!$result) {
        die($connection->error);
    }

    return $result;
}

function destroySession()
{
    $_SESSION = [];

    if (session_id() != "" || isset($_COOKIE[session_name()])) {
        setcookie(session_name(), '', time() - 2592000, '/');
    }

    session_destroy();
}

function sanitizeString($var)
{
    global $connection;
    $var = strip_tags($var);
    $var = htmlentities($var);
    $var = stripslashes($var);

    return $connection->real_escape_string($var);
}

是的我是菜鸟

0 个答案:

没有答案