php - Can't insert datetime to MySql -


This is strange when I get a date time: $ date = date ("Ymd H: i : S "); and try putting it into the database, it will insert null . The column I inserted is a datetime. It does not matter which column I change the data, it will still include zero.

I hope someone can help me!

Because column

in your query instead of a routine
  $ sql = "... datefield = '$ date' ....";  

do

  $ sql = "... datefield = TIMESTAMP ('$ date') ....";  

Obviously .... represents your SQL at that point.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -