On Wed, 5 Dec 2001 09:01, [EMAIL PROTECTED] wrote: > I have added a new column in an existing MYSQL table called > "event_date" - type: DATE, NULL default. > > This database field will be filled if and when the field in the HTML > form is complete. When I added the new field to MySQL, it > automatically assigned NULL to all the existing records - which is what > I wanted it to do. > > I tested the HTML form, and when someone enters a date in the HTML > form, the date appears correctly in the table field. Perfect. > > Now my question: When the HTML form date field is left blank and the > form is submitted, instead of putting "NULL" in the MySQL event_date > field, I found: 0000-00-00. Is this because the form is submitting an > " " to the database field? > > Is there some kind of if/then statement I should use so that when the > field is empty, "NULL" will be entered into that table field? > > Thank you, Shawna
If memory serves me correctly, you need to test for an empty variable; if empty, assign it the value NULL (no quotes around it!) -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Buy Land Now. It's Not Being Made Any More. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]