MySql 1366 Error Incorrect Integer Value

  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Joined: Nov 18, 2007
  • Posts: 429
  • Status: Offline

Post March 6th, 2009, 4:00 pm

MySQL 1366 Error Incorrect Integer Value for Column 'columnname' at Row 1

I'm pulling my hair out. I need some sweet, head-bangin' distortion after this one.

I could have sworn my query was working earlier but now it's not. So i logged in phpmyadmin and ran my query and it returned this error.

The actual column is an int(11) and set to NULL and default value is 0.

The column is usually going to be left blank so it can be empty. Therein lies the problem when the query runs without any value for my column it returns the 1366 error.

I just don't understand why this is happening to a NULL field. Moreover, when the value is empty it should default to 0 anyway and populate the column. Right? So what is the incorrect integer value?

Can anybody shed some light on this issue for me?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 6th, 2009, 4:00 pm

  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post March 6th, 2009, 4:11 pm

How exactly does your SQL query looks? If it has variables in there, keep those variables in there (In the PHP).
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • dark_lord
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jan 14, 2009
  • Posts: 162
  • Loc: India-Kolkata
  • Status: Offline

Post March 6th, 2009, 10:39 pm

@devilwood

when it's empty it'll add null and not 0

and for integer i have encountered that problem, it works sometimes :D

it's better to use VARCHAR with NULL or INT with NOT NULL and default value 0
Wrap Up your Big Url | Mariana World Community
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Joined: Nov 18, 2007
  • Posts: 429
  • Status: Offline

Post March 7th, 2009, 5:25 pm

My query was just a straight forward insert like

Code: [ Select ]
$qry = "INSERT INTO table1(myscore) VALUES('')";


My apologies for not being more thorough with my explanation as that would have helped, but dark_lord picked up what I was getting at since he's yanked his hair out on this one already too. I think he's got me fixed up if all I got to do is change the field to NOT NULL.
  • dark_lord
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jan 14, 2009
  • Posts: 162
  • Loc: India-Kolkata
  • Status: Offline

Post March 8th, 2009, 6:09 am

devilwood wrote:
dark_lord picked up what I was getting at since he's yanked his hair out on this one already too.

:hmm:
indeed, it returns true
:mrgreen:
Wrap Up your Big Url | Mariana World Community

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: ScottG and 277 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.