Code: Select all
function update_rules ($tid) {
$rules = mysql_real_escape_string(stripslashes(htmlspecialchars($_POST['rules'])));
$sql = sprintf("insert into T_Rules set rules='%s', tid=%d, updated=NOW() on duplicate key update rules='%s'",$rules,$tid,$rules);
mysql_query($sql);
}
Here is the problem: on updates the rules field is blank after the query executes.
Here is what I have tested so far:
- The query reports no error.
If I hard code the the value for $rules in the "on duplicate key" section, it properly updates the field.
If I hard code the the value for $rules as the third parameter for sprintf, it properly updates the field.
When I echo the sql statement, the sql statement shows that the $rules value is being added at all desired positions in the string.
If I echo the sql statement and run it through phpMyAdmin, it properly updates the code.
If i rewrite the sql without the "on duplicate key" section it will properly create a record with the correct $rules value, however when running it with the "on duplicate key" section the rules value is blank even when a new row is created.
If I rewrite the sql as an update query, it continues to have the same problem.
I have checked user permissions and that is not a problem ... even with full permissions the problem is occurring.
I can echo $rules and the value will appear ... even after the mysql_query statement.
I have also tried creating a seperate variable for the "on duplicate key" section, it has the same problem.
Hopefully, I'm overlooking something simple.