PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 20, 2022

[FIXED] Problem with the integer value in an SQL syntax: #1366 error

 February 20, 2022     phpmyadmin, sql     No comments   

Issue

I was making a php website with some forms that let you make a form which let's you make an account, but for some reason when I was checking the SQL I was using inside phpmyadmin...

The SQL code it gave me an error that of

#1366 Incorrect integer value

Here is the SQL code I was checking:

INSERT INTO Users VALUES ('','$username','$password','0','empty')

The weird thing about this is the fact that the integer ID, which is in auto-increment, as I've learned it should be blank in the syntax like I've done (the ID column is the first one in my table)


Solution

When you are inserting rows into a table, the best practice is to always list the columns:

INSERT INTO Users (col1, col2, col3, col4)
    VALUES ('', '$username', '$password', '0', 'empty');

I don't know what your column names are, so you have to fill them in.

If you are writing application code, another best practice is to use proper parameters rather than munging a query string with values.



Answered By - Gordon Linoff
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing