SQLSTATE[HY000]: General error: 1366 Incorrect integer value: Any Solution?

php
20,304

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.'")');
Share:
20,304
Alon Eitan
Author by

Alon Eitan

BY DAY: Awake BY NIGHT: Asleep

Updated on July 07, 2022

Comments

  • Alon Eitan
    Alon Eitan 4 months

    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 !

    • Alon Eitan
      Alon Eitan over 6 years
      Pretty easy to understand - You're trying to insert an empty string into an INT type field (guid)
    • Anant - Alive to die
      Anant - Alive to die over 6 years
      remove guid from column name and remove it's corresponding first "" from values. because i think that field is primary key and auto-incremented
    • Jay Blanchard
      Jay Blanchard over 6 years
      Your query is at risk for SQL injection attacks.
    • chris85
      chris85 over 6 years
      I hope you escaped these values and hashed the password.
  • Alon Eitan
    Alon Eitan over 6 years
    @CreyJR If this answered your question, than you should accept it so the user will get their credit and rep.
  • Admin
    Admin over 6 years
    Done for me , it's ok ? :)