I want a value to be set to NULL
if nothing is put into the text box in the form I\'m submitting. How can I make this happen?
I\'ve tried inserting \'NULL
Use NULL
(without the quotes around it).
UPDATE users SET password = NULL where ID = 4
The problem you had is most likely because mysql differentiates between null written in capital letters and null written in small case.
So if you used an update statement with null, it would not work. If you set it to NULL, it would work fine.
Thanks.
Assuming the column allows a null setting,
$mycolupdate = null; // no quotes
should do the trick
Don't put NULL
inside quotes in your update statement. This should work:
UPDATE table SET field = NULL WHERE something = something
You should insert null
, not the string of 'NULL'
.
UPDATE MyTable
SET MyField = NULL
WHERE MyField = ''