警告:mysqli_query()期望参数1为mysqli,第16行给出的字符串

时间:2017-04-02 08:41:53

标签: php sql

$result=mysqli_query($connection,$query);
if(mysqli_affected_rows($connection)==1)

1 个答案:

答案 0 :(得分:0)

你的$ connection参数是一个字符串,而它应该是一个mysqli对象。来自php docs

$link = mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* Create table doesn't return a resultset */
if (mysqli_query($link, "CREATE TEMPORARY TABLE myCity LIKE City") === TRUE) {
    printf("Table myCity successfully created.\n");
}