if (!empty ($_POST['login_value']) && !empty ($_POST['pass_value'])) { // если все поля заполнены
$s_name = $_POST['login_value'];
$s_pass = md5 ($_POST['pass_value']);
$query = mysqli_query ("SELECT * FROM users WHERE username = '.$s_name.'", $connect);
if (!empty ($query["id"])) {// если такой пользователь есть
echo "<div id = 'meta.answer'>Пользователь с таким ником уже существует!</div>";
} else {
echo "<div id = 'meta.answer'>Вы успешно зарегистрированы!</div>";
$good_query = mysqli_query ("INSERT INTO users (username, password, coins, lvl) VALUES ('.$s_name.', '.$s_pass.', 20, 1)", $connect);
}
} else {
echo "<div id = 'meta.answer'>Заполните все поля!</div>";
}
}
错误:
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in /home/u818352377/public_html/index.php on line 35
如果你不明白。 php在这一行中发现错误:$query = mysqli_query ("SELECT * FROM users WHERE username = '.$s_name.'", $connect);
答案 0 :(得分:0)
正是它的意思。
Procedural : mysqli_query($connect,"SELECT * FROM..."):
Object Oriented: $connect->query("SELECT * FROM");
但是你应该听别人说,你应该使用预备语句而不是像这样在查询中添加变量。
答案 1 :(得分:0)
错误是mysqli_query中的参数序列。
正确的顺序如文档中所示:
mysqli_query(mysqli $ link,string $ query [,int $ resultmode = MYSQLI_STORE_RESULT])
因此,您应该将其更改为$query = mysqli_query ("SELECT * FROM users WHERE username = '.$s_name.'", $connect);
$query = mysqli_query ($connect,"SELECT * FROM users WHERE username = '.$s_name.'");
还有其他的mysqli_query。