[thelist] PHP/MySQL Error: Out of range value

Pringle, Ron RPringle at aurora-il.org
Wed Jan 31 13:51:55 CST 2007

Hi all-

Having a problem that seems to be plaguing MySQL 5.x installs in general from what I can see in googling this.

Running PHP 5.1.x and MySQL 5.x. attempting to insert a record into a table that has an integer field called userID, which holds a 10 digit number. Previously, I was inserting stored values from a session directly into the insert statement, and the insert worked fine.

Now I've changed it so I can clean the session data first before storing it. So each session value gets assigned to a variable and then the insert statement is built from those. Suddenly, I am getting the following error:

"Out of range value adjusted for column 'userID' at row 1"

The actual value in my test that I'm attempting to insert into the userID is: 1152549622

Thinking it might be a string versus integer thing, I tried inserting it specifically as an integer using intval($userID) and got the exact same result. I've read via Google that this appears to be a problem with MySQL 5 in strict mode, which is my case, but I'd rather not turn of strict mode and would rather properly code my insert statement. Only I can't figure out the actual problem.

The column in the table is defined as: userID[int(10), NOTNULL]

Here is the code I'm using for the insert statement:

$deptName =	htmlentities($_SESSION['deptName']);
$eventType = htmlentities($_SESSION['eventType']);
$category =	htmlentities($_SESSION['category']);
$title = htmlentities($_SESSION['title']);
$summary = htmlentities($_SESSION['summary']);
$description = htmlentities($_SESSION['description']);
$location =	htmlentities($_SESSION['location']);
$userID = $_SESSION['userid'];
$tableFields = 'deptName, eventType, category, title, summary, description, location, userID';
$tableValues = '\'$deptName\', \'$eventType\', \'$category\', \'$title\', \'$summary\', \'$description\', \'$location\', \'$userID\'';
mysql_query("insert into tbl_event ($tableFields) values ($tableValues)") or die(mysql_error());

I feel like I'm missing something obvious. Any help would be appreciated.


More information about the thelist mailing list