I searched almost whole internet, but could not find something similar, yet my question looks so simple.
I have a php code like so:
$id = 1; if (!isset($_POST['port1'])) { $port1 = null; } ... which simply checks if submitted value is empty or not, if it is empty, then variable $port1 = null;
then, further in the code, I need to insert this value/update it in the database
$sql_update = ("UPDATE names_10 SET `digName1`=$port1 WHERE `device_id`='$id'"); ...which should set the "digname1" to null. but it won't! I tried every combination, every type of quotes, but every time I got UPDATE error..
any ideas?
nullin a string in php is not the same asNULLas a value in a query. I think you should solve this by using parameters rather than munging the string.