Page 1 of 1

Set MySQL cell to NULL

Posted: Thu Dec 25, 2008 3:21 pm
by xQuasar
How do you do it via PHP? I've tried, but the following methods don't work and I'm out of ideas...

Code: Select all

$saltQuery = "UPDATE accounts set salt=NULL where name = '$tusername'";

Code: Select all

$saltQuery = "UPDATE accounts set salt=(NULL) where name = '$tusername'";
Both don't work :( Well, with PHP anyways.

In MySQL Query Browser,

UPDATE `accounts` set `salt`=NULL where `name` = 'name';

WORKS. :(

Re: Set MySQL cell to NULL

Posted: Thu Dec 25, 2008 3:30 pm
by aditya2071990
Did you try:

Code: Select all

$saltQuery = "UPDATE accounts set salt='' where name = '$tusername'";
This will work if in the database, the salt field is not set to "not_null", and if the default value is null...

Re: Set MySQL cell to NULL

Posted: Thu Dec 25, 2008 3:34 pm
by xQuasar
`salt` varchar(32) default NULL

^ That's the column. And I've tried it, it doesn't work with what I'm trying to do.

Re: Set MySQL cell to NULL

Posted: Thu Dec 25, 2008 3:39 pm
by aditya2071990
Are salt and name the only two fields in the table? If they are not, try and omit that from the sql command at all, and fill some other field with some data, then automatically, salt gets a value Null

Code: Select all

$saltQuery = "UPDATE accounts set someOtherField='someOtherValue' where name = '$tusername'";