MySql 1366 Error Incorrect Integer Value

  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

How exactly does your SQL query looks? If it has variables in there, keep those variables in there (In the PHP).
  • dark_lord
  • Graduate
  • Graduate
  • User avatar
  • Posts: 162
  • Loc: India-Kolkata

Post 3+ Months Ago

@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
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

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
  • Posts: 162
  • Loc: India-Kolkata

Post 3+ Months Ago

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:

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 125 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.