Out of range value

Discussion in 'MySQL' started by izlik, Jun 23, 2007.

  1. #1
    hello, im trying to use the Simpcms news script for my php page. but when the addons is installed etc i get this error "Out of range value adjusted for column 'id' at row 1" when trying to post anyting and was told it's my mysql side's problem and wonder if anyone knowwhy i could get this error ?
     
    izlik, Jun 23, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you find the query that threw this error?

    I had a similar problem when installing an IPB once. It turned out that i had to change the STRICT_MODE settings to make the script working. The query that caused the error tried to insert an empty value in the id field, and when STRICT_MODE_ALL is enabled mysql will throw an error as it expects an integer (or preferrable nothing, if auto_increment is active on that field)
     
    UnrealEd, Jun 24, 2007 IP
  3. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #3
    I have this problem also. When I installed mysql on my XP box, the default was strict, so I left it. Should I have unchecked it? I cannot insert anything into a table because when I leave the id field (auto_increment) blank, I get an error.
    Ex: insert into table_name values ('', 'text');
    Where the first empty field as denoted by the apostrophes, is empty, and where 'text' is be inserted into a varchar field. When I put a number in the first field, then it works. Weird.
     
    lektrikpuke, Feb 11, 2008 IP
  4. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #4
    okay, setting mysql to not strict fixes the problem, but I assume there's a reason the default is set to strict. So, how should I insert data into a table with an auto_increment field (in strict mode)?
     
    lektrikpuke, Feb 11, 2008 IP
  5. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #5
    Found the answer on another forum: Just use NULL instead of the empty '' set. Hope this helps someone else out.
     
    lektrikpuke, Feb 21, 2008 IP
  6. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Careful with NULL.

    If you ever want to group by that field you will find your self missing records.

    You should set it to another value other then NULL so you can always group by it if needed.
     
    LittleJonSupportSite, Feb 22, 2008 IP
  7. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #7
    I would use something else if I knew what to use when in strict mode other than NULL when using auto_increment.
     
    lektrikpuke, Feb 23, 2008 IP