I have 2 different servers:
one running Plesk Panel (PHP 5.2.13 & MySQL 5.0.45-community-nt),
and the other running Zend Server 5.5 (PHP 5.2.17 & MySQL 5.1.50-community).
I have a table in mysql DB on both servers as follows:
CREATE TABLE `test_table` ( `id` int(11) NOT NULL auto_increment, `num` int(5) NOT NULL, `txt` text NOT NULL, `ste` bigint(5) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1
i run the following php code on both servers:
mysql_query("START TRANSACTION"); if(!mysql_query("insert into test_table(num,txt) values(1,'sd')")) { echo "ERROR OCCURED.
".mysql_error(); mysql_query("ROLLBACK"); exit; } else { echo "Successful insertion"; mysql_query("COMMIT"); exit; }
i get the query successfully run on my Plesk Server (with warnings – if run SHOW WARNINGS query, i get “Field ‘ste’ doesn’t have a default value”, but the row is inserted and mysql_query returns true)
but on my Zend server, mysql_query returns false and the same error is shown. the row is not inserted.
i need the row to be inserted ignoring warnings. i spend a whole day on this and is out of options now.
please help me on this. thanks lot in advance.
2
Answers
It would seem as though the MySQL running on your Zend server is running in Strict Mode. This means that what would otherwise be a warning becomes a fatal error.
See here for information on server modes and how to change them, try disabling Strict Mode, and see if that helps.
can you use the IGNORE keyword? Insert IGNORE into ….. Not sure if it’s a good idea though