简体   繁体   中英

Warning: mysqli_query() expects parameter 1 to be mysqli error

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>"; 
}

I keep getting the mysqli error. Im prtty sure that i'm not using msql in my php.

change this

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

to

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

example mysqli_query( mysqli $link , string $query )

The signature for mysqli_query is:

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

Assuming $db_connects is the variable storing the result of mysqli_connect , you need to flip your arguments to fit:

mysqli_query($db_connects, $tbl_status); 

mysqli_query documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM