I study php mysql from a book, create a users table and try to add data, to which an error flies. I changed the quotes for single and repeated twice single quotes - nothing happened.

mysql> INSERT INTO users -> VALUES (1, "Mike", "Greenfield", "mike@greenfieldguitars.com", -> "http://www.facebook.com/profile.php?id=777666", -> "@test1test"); ERROR 1064 (4200): Erreur de syntaxe pr\00E8s de '"Mike", "Greenfield", "mikegreenfieldguitars.com", "http://www.facebook.com/profile.php?id=777666", "@test1test", \00E0 la ligne 1 

enter image description here

It seems that the whole thing is in the encoding, but through phpmyadmin it does not change and asks to set the root password, which cannot be set via the console due to incorrect encoding enter image description here

  • And what is the structure of the table? What are the columns? autoincrement at the first column or not? - Alexey Shimansky
  • @ Alexey Shimansky added the necessary data for these data with the correct types (I apologize, but I just started learning the DB and therefore I don’t know what autoincrement is and how to check it) I do everything according to the book by Brett McLaughlin "Exhausting manual" and it’s at this point that I ’m stuck - Atomrr
  • Well, for example, add to the question what the DESCRIBE users query displays - Alexey Shimansky
  • @ Alexey Shimansky added - Atomrr
  • Most likely, the letter è (not e ) is present in the Mike name - it is nonstandard, and it is impossible to simply save something other than Latin in the table - you need to configure collation and encodings. - yeputons

4 answers 4

try to change the encoding to utf8_general_ci

write in console

 ALTER TABLE users CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci 
  • via phpmyadmin tried to change the encoding - it did not work out that the message “The phpMyAdmin configuration file contains MySQL default settings, according to which the root user is not set a password. Such settings make the MySQL server vulnerable to unauthorized access, therefore it is strongly recommended to set a password for user root. Tried to set a password through the console mysql - the same error with the syntax - Atomrr
  • After the command did not change - Atomrr

The issue was resolved by removing the WAMP assembly and installing one mysql. Unfortunately, I did not understand why such magic happened, but now the data has been successfully added. Thanks to everyone who tried to help.

    And if you write a standard?

     INSERT INTO users VALUES (1, 'Mike', 'Greenfield', 'mike@greenfieldguitars.com', 'http://www.facebook.com/profile.php?id=777666', '@test1test'); 

      I do not know how from the command line, but you forgot to specify in which fields to write this data. The request should look like this:

       INSERT INTO users (id, name, surname, email, facebook, pass) VALUES (1, "Mike", "Greenfield", "mike@greenfieldguitars.com", "http://www.facebook.com/profile.php?id=777666", "@test1test"); 
      • 2
        Usually, it is necessary to list the fields if not all of them are inserted. If absolutely data is inserted into all fields - their names do not have to be specified - Alexey Shimansky
      • Thanks I'll know. Never had to fill in all fields) - toxxxa