BDabrowski Posted January 8, 2010 Share Posted January 8, 2010 I have a column in a table that is set to allow NULL, and default is NULL. When a record is inserted, with no value, the field is correctly NULL. Every time I run an UPDATE on the table, the field becomes an empty string. The syntax I'm using is SET field=NULL, otherfield . . . .etc. I've written the query back to the screen to ensure that it is attempting the proper query. I get no mysql errors, but it keeps setting the field to a empty string. In PHPMyAdmin, if I run the UPDATE query with the SQL tool, it still makes the field an empty string. The only way I can set an existing record back to NULL is to select to edit the record and use PHPMyAdmin's form to run the query. After setting the field back to NULL with the pre-built form, I can even copy and paste the query that the form created back into the SQL tool and it still inserts an empty string rather than NULL, when that exact same query just inserted the NULL value via the form. The host says it's a programming issue. What am I missing? Quote Link to comment https://forums.phpfreaks.com/topic/187651-update-null-wont-work/ Share on other sites More sharing options...
fenway Posted January 13, 2010 Share Posted January 13, 2010 Are you sure you're not quoting it by accident? Quote Link to comment https://forums.phpfreaks.com/topic/187651-update-null-wont-work/#findComment-994363 Share on other sites More sharing options...
AngelG107 Posted January 14, 2010 Share Posted January 14, 2010 <?php $server = "localhost"; //replace this value $user = "root"; //replace this value $pass = ""; //replace this value $db = "xpressde"; //replace this value $table_name = "clients"; //replace this value $field_name = "firstname"; //replace this value mysql_connect($server,$user,$pass); mysql_select_db($db); $query = "UPDATE $table_name SET $field_name=NULL"; mysql_query($query); ?> I already tried out that code in my local server, and it works perfectly. If it doesn't work, it should be something related to the server. Tell them to check the logs, if the server is being run on linux, they should find all the logs at : /var Quote Link to comment https://forums.phpfreaks.com/topic/187651-update-null-wont-work/#findComment-994614 Share on other sites More sharing options...
BDabrowski Posted January 14, 2010 Author Share Posted January 14, 2010 Server version: 5.0.85-community The tables/DB is MyISAM. I've been seeing something about certain types not allowing NULL. Tried the SHOW CREATE TABLE query, but PHPMyAdmn gave me this: Full Texts Table Create Table nhb_users CREATE TABLE `nhb_users` ( `users_id` int(11) NO... I'm sure there's more to it. I've avoided the issue for now, so feel no obligation to follow up, but I'll still be interested to figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/187651-update-null-wont-work/#findComment-994627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.