2

As you can read in the title, I have a problem with my INSERT. I am working on a register page, so here is the code I have :

if ($AllGood) { $Data = $DB->prepare("INSERT into `users` (pseudo, email, password, skype, reg_date, rank, picture, reg_ip, last_ip, group) VALUES (':pseudo', ':email', ':password', ':skype', ':date', ':rank', ':picture', ':reg_ip', ':last_ip', ':group')"); $Data->bindParam(':pseudo', $pseudo, PDO::PARAM_STR); $Data->bindParam(':email', $email, PDO::PARAM_STR); $Data->bindParam(':password', $pswd, PDO::PARAM_STR); $Data->bindParam(':skype', $shit, PDO::PARAM_STR); $Data->bindParam(':date', $date, PDO::PARAM_STR); $Data->bindParam(':rank', $rank, PDO::PARAM_STR); $Data->bindParam(':picture', $shit, PDO::PARAM_STR); $Data->bindParam(':reg_ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR); $Data->bindParam(':last_ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR); $Data->bindParam(':group', $shit, PDO::PARAM_STR); $Data->execute(); $Data->closeCursor(); // End the connexion echo "YOU DONE PHP, GO TAKE A BREAK"; } 

The following code is perfectly executing to the last line. But when I go check in my DB I don't have anything :// ( I don't have a problem with the connection at all , everything is fine about it ).

3 Answers 3

2

group is a reserved key word so u need to backtick as

`group` INSERT into `users` ( pseudo, email, password, skype, reg_date, rank, picture, reg_ip, last_ip, `group` ) 

Check here

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

Sign up to request clarification or add additional context in comments.

Comments

1

I suggest to avoid this issue by design, you can change column name like (user_group) or to another name instead using backticks.

Comments

0

Anythi e you use a MYSQL RESERVED KEYWORD You need to escape it with backticks `, this will let database understand that it is a column

`group` 

From documentation

Certain words such as SELECT, DELETE, or BIGINT are reserved and require special treatment for use as identifiers such as table and column names. This may also be true for the names of built-in functions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.