Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have an issue and i can't figure out where is the problem. on local system everything works fine with php and mysql, but on live server i get an error from mysql that some column don't have default value.

i know i should insert columns's default values or set proper definitions in table schema. but do anyone have ideas about what mysql configuration causing this. so i can change on my local configuration to adopt this and get error like production server.

and now after few time ago i did a test. on local and server i run this script.


mysql_connect('localhost','*****','*****') or die(mysql_error());
mysql_select_db('****') or die(mysql_error());

var_dump(mysql_query('INSERT INTO `advertise` set name_en=\'\'') or die(mysql_error()));


on local its echo boolean true

on server its echo Field 'name_ar' doesn't have a default value

and here is table schema that i have exported from phpmyadmin

-- Table structure for table `advertise`

  `uid` varchar(255) NOT NULL,
  `name_en` varchar(255) NOT NULL,
  `name_ar` varchar(255) NOT NULL,
  `content` varchar(255) NOT NULL,
  `type` int(11) NOT NULL,
  `size` varchar(255) NOT NULL,
  `impressions` int(11) NOT NULL DEFAULT '0',
  `impression_limit` int(11) NOT NULL DEFAULT '0',
  `link` varchar(255) NOT NULL DEFAULT '',
  `status` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)

and when i see the inserted record's columns i see its blank. and i facing this problem. columns like uid,name_ar and columns like 'not null' giving me problem.

share|improve this question

closed as off-topic by Falcon Momot, mdpc, Ward, dawud, Michael Hampton Sep 27 '13 at 23:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic. Please see the Help Center for more information on topicality. The best advice we can give you is to hire a professional to help you out." – Falcon Momot, Ward, Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.

you need to provide more information if you want others to be able to help you. what's different on the two servers. – Drew Khoury Sep 23 '13 at 9:45
let me know what more informations i can give, i can paste my local my.ini but i have no access on server's mysql config ini – dev.mraj Sep 23 '13 at 10:01
what's different on the two servers? – Drew Khoury Sep 23 '13 at 11:01
Compare the structure of both the tables (production and local) and let us know the difference. – Wasif Sep 23 '13 at 11:30
hi see my updated question – dev.mraj Sep 23 '13 at 12:12
up vote 1 down vote accepted

You need to change sql_mode as @Maz suggested. Set its value to STRICT_ALL_TABLES.

share|improve this answer
how to set sql_mode – dev.mraj Sep 23 '13 at 13:35
Thanks i got it... – dev.mraj Sep 23 '13 at 13:37

This happens mainly in windows systems. If you are developing on unix based system and deploy in a windows environment this happens. I'm just assuming that your dev and live server are in different OS.

You might be looking for sql_mode

share|improve this answer
hi maz, sorry but my local window8 and server win server 2008 – dev.mraj Sep 23 '13 at 10:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.