I have the following code:
$query = "UPDATE jobs SET `ipt` = '$ipt', `prejobform` = '$prejobform', `fileddate` = '$fileddate' WHERE `job_id` = '$jobid'";
$result = mysql_query($query);
if (!$result) {
//ERROR LOGGER HERE
echo mysql_error();
}
else {
header('Location: view_job.php?jobid='.$jobid);
}
This code is redirecting like it is behaving correctly, but when I check the database, the fields have not been updated. I’m sure the problem is something simple that I’m missing, but I’m at a loss to find the problem.
For an
UPDATEquery,mysql_queryreturns true if the query succeeded (was parsed and executed correctly), not only if it did really update any rows.If the underlying table is
InnoDBand you have started a transaction earlier, the query won’t commit transaction implicitly and it will roll back when you exit the script or disconnect.