警告:mysqli_query()需要至少2个参数,1在第27行的C:\ Apache24 \ htdocs \ TheWorld \ index.php中给出
警告:mysqli_num_rows()要求参数1为mysqli_result,在第29行的C:\ Apache24 \ htdocs \ TheWorld \ index.php中给出null
警告:mysqli_query()需要至少2个参数,1在第31行的C:\ Apache24 \ htdocs \ TheWorld \ index.php中给出
警告:mysqli_num_rows()要求参数1为mysqli_result,在第33行的C:\ Apache24 \ htdocs \ TheWorld \ index.php中给出null
警告:mysqli_query()需要至少2个参数,1在第55行的C:\ Apache24 \ htdocs \ TheWorld \ index.php中给出
.... 我的代码是:
第27行:
$u_check = mysqli_query("SELECT username FROM users WHERE username='$un'");
第29行:
$check = mysqli_num_rows($u_check);
第31行:
$e_check = mysqli_query("SELECT email FROM users WHERE email='$em'");
第33行:
$email_check = mysqli_num_rows($e_check);
并在第55行:
$query = mysqli_query("INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','$d','0','Write something about yourself.','','','no')");
有人可以帮忙吗?
答案 0 :(得分:2)
这条线你必须改变
$u_check = mysqli_query("SELECT username FROM users WHERE username='$un'");
应该是这个
$u_check = mysqli_query($connect,"SELECT username FROM users WHERE username='$un'");
同样适合您插入查询
应该是这个
$query = mysqli_query($connect,"INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','$d','0','Write something about yourself.','','','no')");
$connect
是您用来连接数据库的变量。我不必说你可能
这个变量有不同的名称。
查看链接以获取更多信息http://php.net/manual/en/mysqli.query.php
答案 1 :(得分:0)
您应该将数据库连接传递给“mysqli_query”函数。
例如:
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
$result = mysqli_query($link, "CREATE TEMPORARY TABLE myCity LIKE City");
答案 2 :(得分:0)
连接:
$username= "user";
$password= "password";
$host= "ip local host";
$database= "databasename";
$sql1 = mysqli_connect("$host", "$username", "$password", "$database");
if(!$sql1){
echo "error to connect server.";
die();
}
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
然后如果你想执行你的查询,它应该是这样的。
$mysql = mysqli_query($sql1,"select * from table");