I have a table like this
CREATE TABLE test(a int, b int);
The values to the table are inserted from dynamic input
$a, $b (PHP variables)
$query = "UPDATE test set a=$a where b = $b";
pg_query($db, $query);
This doesn't work when $a is empty (i.e when the user doesn't enter any value for a form field from the table). How to I get around this?
set a='$a'? If $a is empty, it will attempt to insert an empty value. If your table accepts null values, it should work.NULLand empty''are very different values.if (!$value)both would be parsed as false.