I am trying to insert a table, and one of the columns is a date column. I have it set to "NULL" in my database using PHPMyadmin.

It will go through if there is a valid date, but it won't work if I submit nothing.

I read somewhere that "/n" is suppossed to be the same is null but that didn't get me far.

EDIT: the error message is:

Incorrect date value: '' for column 'specific_date' at row 1

    Try using the SET parameter instead of list in your insert statement

    INSERT INTO tblWhatever SET field='$value', field2='$value2'

    simply don't include the date field if its invalid... If its a DATETIME, TIME, or DATE then mysql should set it to 0000-00-00 00:00:00, etc

      If you specifically want to insert NULL into that column then mysql will recognise the value NULL in a query

      
      $sql = "INSERT INTO tblWhatever SET specific_date = NULL";
      
      

      /n is equivalent to a newline on a windows platform and meaningless in sql - or rather it's going to be treated as a character string and is therefor invalid in a date column.

        Write a Reply...