警告:mysqli_query()期望参数1为mysqli错误

时间:2013-03-30 05:58:41

标签: php mysql mysqli

include_once("php/db_connects.php");

$tbl_status = "CREATE TABLE IF NOT EXISTS status ( 
                id INT(11) NOT NULL AUTO_INCREMENT,
                osid INT(11) NOT NULL,
                account_name VARCHAR(16) NOT NULL,
                author VARCHAR(16) NOT NULL,
                type ENUM('a','b','c') NOT NULL,
                data TEXT NOT NULL,
                postdate DATETIME NOT NULL,
                PRIMARY KEY (id) 
                )"; 
$query = mysqli_query($tbl_status, $db_connects); 
if ($query === TRUE) {
    echo "<h3>status table created </h3>"; 
} else {
    echo "<h3>status table NOT created </h3>"; 
}

我一直收到mysqli错误。我很确定我在我的php中没有使用mysql。

2 个答案:

答案 0 :(得分:1)

更改此

$query = mysqli_query($tbl_status, $db_connects); 

$query = mysqli_query($db_connects, $tbl_status); 

示例 mysqli_query(mysqli $ link,string $ query)

答案 1 :(得分:0)

mysqli_query的签名是:

mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] )

假设$db_connects是存储mysqli_connect结果的变量,您需要翻转参数以适应:

mysqli_query($db_connects, $tbl_status); 

mysqli_query documentation