Good day, help sort out please. Created a form, when downloading to the hosting gives an error:

This code works without problems on the local OpenServer:

$sql = "INSERT INTO wp_db (ФИО, Дата_рождения, Телефон, Электронная_почта, Первый, Второй, Третий, Четвертый ) VALUES ('$_POST[name]', '$_POST[birth]', '$_POST[phone]', '$_POST[email]', '', '', '', '')"; if ($conn->query($sql) === TRUE) { echo 'Новая запись успешно создана'; } else { echo "Ошибка: " . $sql . "<br>" .$conn->error; } 

And after uploading to the hosting, the form, when sent, gives:

You have an error in your SQL syntax; check the syntax for your right syntax to use, near date, birth date, phone at line 1

After searching for information by mistake, put the sql variables in ``

  $sql = "INSERT INTO `wp_db` (`ФИО`, `Дата_рождения`, `Телефон`, `Электронная_почта`, `Первый`, `Второй`, `Третий`, `Четвертый`) VALUES ('$_POST[name]', '$_POST[birth]', '$_POST[phone]', '$_POST[email]', '', '', '', '')"; 

Then he began to produce such an error:

Unknown column 'Name' in 'field list'

In this case, the name field exists in the database.

MySQL configurations: OpenServer: 5.6.26 Hosting: 5.5.35-33.0

Update

The encoding of the table is utf8_general_ci , in the code after connecting to the database and selecting the table goes mysql_query("set names utf8"); When creating a table in the database

 mysql_query("SET NAMES 'utf8'"); mysql_query("SET CHARACTER SET 'utf8'"); mysql_query("SET SESSION collation_connection = 'utf8_general_ci'"); 

In the form itself, accept-charset="UTF-8" written. That is, it seems like everywhere utf-8 is worth it.

  • And the encoding in the database and when connecting the same in the query text? can do set names utf-8, make sure that the text is in utf, that the base is in utf - Mike
  • one
    Well, firstly, I would not advise you to call the fields Russian names, and secondly, if everything is fine with the encoding, try to enter some phpmyadmin, choose insert and copy the fields to your request from there - VK

0