[thelist] Setting a MySQL value to NULL using PHP

Jay Blanchard jay.blanchard at niicommunications.com
Tue Apr 30 15:53:01 CDT 2002

I think this si an SQL problem. PHP is just a way to run a query against the
database, no different than if you did it from the command line, right?

NULL should be 'NULL', incidentally...

I just did a similar query from PHPMyAdmin where I tried updating a
'auto_increment' column, it said 'error: duplicate entry 0' which makes

Next I tried it on a column that is specified as 'not null' and has a
default value of '0'. The query updated the field to have a value of '0'.

Next I tried it on a column specified as 'null' (or, not 'not null') and
with a default value left blank. The fields were updated to have a value of

It seems like 'NULL' will always put a value of '0' in a field...

I had tried without quotes, with single quotes, and a number of other ways.
What i really need is NULL, which is the absence of any value. '0' is a
value, although if push comes to shove I could use that (requiring some
other changes).

Thanks John!


More information about the thelist mailing list