TipuZaynSultan
TipuZaynSultan

Reputation: 783

MySql Query Running in localhost but not in the Web Server

I have a database table something like this...

CREATE TABLE IF NOT EXISTS `example` (
  `id` varchar(78) COLLATE latin1_general_ci NOT NULL,
  `username` varchar(78) COLLATE latin1_general_ci NOT NULL,
  `password` varchar(78) COLLATE latin1_general_ci NOT NULL,
  `reg_date` date NOT NULL,
  `reg_time` time NOT NULL,
  `permission` varchar(78) COLLATE latin1_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

Now I am performing a query from PHP is ...

INSERT INTO `example` (`id`, `username`, `password`, `reg_date`, `reg_time`, `permission`) VALUES ('j652hsL', 'example_user', 'secret', '', '', '');

This query is running Perfectly in my localhost with a warning of course but not problem in data insertion... Yes the reg_date, reg_time & permissions fields are holding 0000-00-00, 00:00:00& *Blank* respectively...But there is no problem with Insertion... Now this same Insertion Query is not running on a certain Web Server... I have a web server and I tested it there it was running with no Error but When I shifted to different Web Server it wasn't running there... I think its a some kind of Server settings issue... But What possibly could stop it from inserting the Data?

Thanks all in advance.

Upvotes: 0

Views: 1612

Answers (1)

Andreas Wederbrand
Andreas Wederbrand

Reputation: 39991

Check if your local server and the web server uses different SQL MODE. Depending on how strict the mode is it handles zero-dates, default values and other things differently.

To get the current setting run show variables like 'sql_mode' on both servers.

Upvotes: 1

Related Questions