0
votes

I'm sorry, but i have a problem on my website when i want to create any account. My error is :

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'guid' at row 1'

And my code is :

$db->query('INSERT INTO accounts (guid, account, pass, level, vip, email, lastIP, question, reponse, pseudo) VALUES ("", "'.$account.'", "'.$pass1.'", "0", "0", "'.$mail.'", "'.$ip.'", "'.$question.'", "'.$reponse.'", "'.$pseudo.'")');

Please help me... Thank you so much, Stackoverflowers :D !

1
Pretty easy to understand - You're trying to insert an empty string into an INT type field (guid)Alon Eitan
remove guid from column name and remove it's corresponding first "" from values. because i think that field is primary key and auto-incrementedAnant Kumar Singh
Your query is at risk for SQL injection attacks.Jay Blanchard
I hope you escaped these values and hashed the password.chris85

1 Answers

3
votes

You are trying to insert an empty string into a column that is expecting an integer. You should probably be inserting an integer. Depending on the setup, you might get away with just inserting a 0 or something but since the column is called guid, that would probably break something. Another option would be to omit it entirely and see if it is set automatically.

$db->query('INSERT INTO accounts (account, pass, level, vip, email, lastIP, question, reponse, pseudo) VALUES ("'.$account.'", "'.$pass1.'", "0", "0", "'.$mail.'", "'.$ip.'", "'.$question.'", "'.$reponse.'", "'.$pseudo.'")');