Out of range value adjusted for column error in php

Sometimes using Mysql 5 with php we got this error Out of range value adjusted for column. Normally this error comes when you are using an auto increment field in your mysql table and you are trying to insert values from php code in this mysql table which has auto increment field.

To avoid this error Out of range value adjusted for column there are possible three solutions but I prefer solution 1 and solution 2.

Solution 1

Use functionality of SQL_MODE


Just Login to the mysql shell and use this command to avoid the error

SET GLOBAL SQL_MODE=”;

It will fix your problem.

Solution 2

Modification in insert query

Sometimes our website hosting company (incase if website is hosted by website hosting company) doesn’t give us permission to use SQL_MODE or sometimes we want to quicker solve this error without contacting the hosting company of our website then use insert query like this

$sql="insert into student values('Adeel', 'Fakhar')";

Instead of $sql="insert into student values('', 'Adeel', 'Fakhar')";

Solution 3

Move back to Mysql 4

So these are the ways to avoid Out of range value adjusted for column error in php.

0 comments: