0

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.

<?php

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`
--

CREATE TABLE IF NOT EXISTS `advertise` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `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`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;

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.

5
  • you need to provide more information if you want others to be able to help you. what's different on the two servers. 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 Sep 23 '13 at 10:01
  • what's different on the two servers? 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 Sep 23 '13 at 12:12
1

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

1
  • how to set sql_mode Sep 23 '13 at 13:35
0

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

1
  • hi maz, sorry but my local window8 and server win server 2008 Sep 23 '13 at 10:00

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