zenlord Posted February 22, 2010 Share Posted February 22, 2010 Hi, For one of my functions, I need to remove a value from a table, so I thought about setting it to NULL: function removeDosLoc($file){ // Remove the old location, if any $res = pg_query(CNX_DOS, "SELECT id,file,category FROM dossiers_location WHERE file = '$file'"); $num = pg_num_rows($res); if ($num !== 0) { $fields = array('file' => NULL); $condition = array('file' => $file); pg_update(CNX_DOS,"dossiers_location", $fields, $condition) or die("removeDosLoc: failed"); } } But I always get the die()-error. I use the same function to set the value to $file, so the function should be working - all I can think of is the 'NULL' that is incorrect? Or not? thanks! /EDIT: oh, and BTW: I checked that $num equals 1, so it is not a problem of $num being > 1 (the column is set to UNIQUE, so it couldn't be that problem...) Quote Link to comment https://forums.phpfreaks.com/topic/192942-pg_update-record-to-null/ Share on other sites More sharing options...
btherl Posted February 23, 2010 Share Posted February 23, 2010 What does pg_last_error() tell you? Quote Link to comment https://forums.phpfreaks.com/topic/192942-pg_update-record-to-null/#findComment-1016493 Share on other sites More sharing options...
zenlord Posted February 23, 2010 Author Share Posted February 23, 2010 Hmmm, added the pg_last_error(), ran it again and it worked. Don't know where I messed up yesterday. THX for your answer and making me try it again Quote Link to comment https://forums.phpfreaks.com/topic/192942-pg_update-record-to-null/#findComment-1016627 Share on other sites More sharing options...
btherl Posted February 24, 2010 Share Posted February 24, 2010 Quote Link to comment https://forums.phpfreaks.com/topic/192942-pg_update-record-to-null/#findComment-1017172 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.