Reputation: 129
Trying to execute SQL query like below in my PHP. It works fine when executed on database.
UPDATE `wp_essx95_cf7dbplugin_submits` SET field_value = 'hiya' WHERE submit_time = '1500944028.4748' and field_name='status'
In my PHP I have two values stored as variable. I'm calling it like this:
$SQL = "UPDATE `wp_essx95_cf7dbplugin_submits` SET field_value = '$status' WHERE submit_time = '$trade_num' and field_name='status'";
$result = mysqli_query($db_handle, $SQL);
return $result;
However it doesn't seem to be working.
Am I writing the statement correctly? How can I further debug the situation, like see the result of the PHP query. I have the PHP function return $result, and echo it on my page, but it doesn't seem to output anything.
echo(setStatus($time, $sts));
Thanks
Upvotes: 0
Views: 61
Reputation: 601
Try escaping the variables and adding a die
statement if an error occurs. Also do not forget to clean the data to prevent mysql injection.
$SQL = "UPDATE `wp_essx95_cf7dbplugin_submits` SET field_value = '".$status."' WHERE submit_time = '".$trade_num."' and field_name='status'";
$result = mysqli_query($db_handle, $SQL) or die(mysqli_error($db_handle));
return $result;
Upvotes: 2