0

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.

5
  • do you have necessary permissions for executing queries on the mysql server Commented May 30, 2014 at 7:36
  • Why don't you write what that warning is you get? And what error does that mysql server give where the question does not execute? Or are we meant to guess that? Commented May 30, 2014 at 7:40
  • Is any other query working? The connection is successful? Commented May 30, 2014 at 7:43
  • Yes... I have necessary permissions actually when I write the query like this... INSERT INTO example` (id, username, password, reg_date, reg_time, permission) VALUES ('j652hsL', 'example_user', 'secret', '0000-00-00', '00:00:00', 'read');` Commented May 30, 2014 at 7:47
  • Yes the connection is successful... If I don't put the permissions value it says there is no Default value set for permissions and when I don't put anything in the reg_date & reg_time it says syntax error... Date & Time format incorrect... Commented May 30, 2014 at 7:49

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes... The old server and the localhost has... sql_mode : NO_ENGINE_SUBSTITUTION

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.