如何修复:警告:mysqli_query()要求参数1为mysqli


How to fix: Warning: mysqli_query() expects parameter 1 to be mysqli?

我正在尝试在主机上安装Arfooo。

首先,我收到了关于的警告

Deprecated: mysql_connect()

修复后,现在我得到这个错误:

function executeQueryWithPrefix($sql, $tablesPrefix)
{
    $sql = str_replace("CREATE TABLE `", "CREATE TABLE `" . $tablesPrefix, $sql);
    $sql = str_replace("INTO `", "INTO `" . $tablesPrefix, $sql);
    //echo $sql."<br>";
    return mysqli_query($sql);
}
function dbConnect($server, $user, $pass, $dbName)
{
    /* install database with prefixed tables */
    mysqli_connect($DB_HOST, $user, $pass, $dbName);
    //mysql_connect($server, $user, $pass) or die('could not connect to mysql');;
    mysqli_query($dbName, 'CREATE TEMPORARY TABLE `table`');
    //mysql_query('create database IF NOT EXISTS ' . $dbName);
    mysqli_select_db($dbName) or die('could not select database');
}

请帮忙!谢谢

$link = mysqli_connect($DB_HOST, $user, $pass, $dbName);
mysqli_query($link, 'CREATE TEMPORARY TABLE `table`');

使用mysqli,您需要将连接保存在变量中,并在每次使用mysqli时提供该变量。

EDIT:一般来说:您需要为您使用的每个与mysqli相关的函数提供连接。