0

I'm having problems updating records to contain NULL values - in particular, a field which is of type Date.

I'm using prepared statements and I've tried the following:

// Fails
$value = NULL;

// Fails
$value = "";

// Fails
$value = "NULL";

all 3 of the above result in a date of 1969-12-31 being entered (0). How do I insert NULL values?

Stomped
  • 2,010
  • 6
  • 21
  • 25
  • What does the definition for your table look like? May you insert a NULL value into this field? – thetaiko Mar 10 '10 at 18:42
  • Yes, it allows null values. If I go into PHP my admin I can do "update tblA set date_field = NULL" sucessfully, or without prepared statements it works fine. – Stomped Mar 10 '10 at 18:43
  • 2
    you're talking about sql here, so could you please show the query you're using to update the row? – Tesserex Mar 10 '10 at 18:43

1 Answers1

1

Did you read the following question/answer: using nulls in a mysqli prepared statement

That seems to be the same issue. Correct me if I'm wrong?

Community
  • 1
  • 1
Josh
  • 10,961
  • 11
  • 65
  • 108