I'm wondering if anyone has seen this problem before. I have a function that's supposed to execute a query, but it ONLY works if I put an "exit;" command after it. In other words, if I stop execution after the query, the query completes correctly. If I allow execution to continue, there are no errors, but the query still does nothing.
I have also printed the variables and query and they are all correct The query works fine if I just plug it into MySQL. Of course printing and exiting eliminates the problem so that isn't even helpful for troubleshooting.
Here's the function:
function updateThis($field, $old_value, $new_value, $aid, $link, $uid)
{
// This query ALWAYS works - regardless which query goes first...
$query = "INSERT INTO AssetHistory (asset_id, field_name, prior_value, user_id) VALUES ('$aid', '$field', '$old_value', $uid)";
mysql_query($query, $link);
// This query ALWAYS does nothing, unless I interrupt the function with an "exit;"...
$query = "UPDATE Assets SET $field = '$new_value' WHERE asset_id = $aid";
mysql_query($query, $link)
or die(mysql_error()."<br>*** ERROR ***<br>".$query);
exit;
return TRUE;
}
Has anyone dealt with this? Do I need a "sleep" loop to slow down the function or something?