Here I am faced with such a problem, what is the error? I checked the code more than once

register.php

<div class="content"> <form method="POST" action="/register" class="reg_form"> <br><input type="text" name="login" > - Логин <br><input type="password" name="password" > -Пароль <br><input type="email" name="email" > - E-Mail <br><br><input type="submit" name="register" value="Регистрация"> </form> <?php if (isset($_POST['register'])) { require_once 'assets/reg.php'; } ?> </div> 

reg.php

 $_POST["login"] = FormChars($_POST["login"]); $_POST["email"] = FormChars($_POST["email"]); $_POST["password"] = GenPass(FormChars($_POST["password"]),$_POST['login']); $login = $_POST["login"]; $email = $_POST["email"]; $pass = $_POST["password"]; if (!$login or !$email or !$pass) exit("<div class='alert'><div class='left_block'></div>Не все поля заполнены!</div>"); $row = mysqli_fetch_assoc(mysqli_query($CONNECT, "SELECT username FROM users WHERE username = '$login'")); if ($row['username']) exit("<div class='alert'>Данное имя пользователя уже используется!</div>"); $row = mysqli_fetch_assoc(mysqli_query($CONNECT, "SELECT email FROM users WHERE email = '$email'")); if ($row['email']) exit("<div class='alert'>Данный адрес электронной почты уже зарегистрирован!</div>"); mysqli_query($CONNECT, "INSERT INTO 'users' VALUES ('','$_POST[login]','$_POST[password]','$_POST[email]','NOW()'") or die(mysqli_error($CONNECT)); echo "<div class='success'>Поздравляем, вы успешно зарегистрировались!</div>"; 
  • You should at least show the full text of the error .... and not just error in your SQL syntax . We need to know how it sounds completely, as indicated by - Alexey Shimansky
  • You have an error in your SQL syntax; I ’m line 1 - Bohdan Troianov
  • near Where? ...... - Alexey Shimansky
  • You have an error in your SQL syntax; check the syntax to use mySQL server; Id; id; username; password; email; regdate;) VALUES ("", 123, 9131b6c45698d925 " at line 1 - Bohdan Troianov
  • @Bohdan Troianov, what do you think religion does not allow? Why do you shove quotes everywhere and everywhere? id,username,password,email,regdate - ArchDemon

2 answers 2

 mysqli_query($CONNECT, "INSERT INTO 'users' VALUES ('','$_POST[login]','$_POST[password]','$_POST[email]','NOW()'") 

Considering the previous answer, I would say that here 'users' is quoted, when it is more correct to

 mysqli_query($CONNECT, "INSERT INTO users (col1, col2, col3, col4, col5) VALUES ('','$_POST[login]','$_POST[password]','$_POST[email]','NOW()'") 
  • preferably column names should be enclosed in reverse quotes ... that is, in "` " - Alexey Shimansky
  • when using such a code, the error does not disappear - Bohdan Troianov
  • @Bohdan Troianov, column names without quotes !!! - ArchDemon

look at the INSERT operator syntax

  • This is not a mandatory element of the operator, so it is indicated in square brackets. Used when you need to change the order of the fields or specify their limited set. - cheops