Insert PHP date into MySQL database -


I need to enter a field from a field in a MySQL database. If the user does not input a date, then Current date should be used. My code is: $ (_POST [date] == 0] {$ ref_date = date ('yd-m');} and {$ ref_date = $ _ POST [date] ; } $ L = "Enter the referral (id, patient, doctor, date) values ​​(default, $ pat, $ doc, '$ ref_date')"; Mysql_query ($ L) or die (mysql_error ());

When I present a date in the form, but when I leave that field, it fixes the exchange of 0000-00-00.

MySQL is expected to be in the format of the format . You have YYYY-DD-MM . Change:

  $ ref_date = date ('Y-D-M'); From  

to:

  $ ref_date = date ('Y-M-D');  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -