I'm having a problem with the UPDATE command as it pertains to a MySQL database.
My query code is this:
$query_fee = "UPDATE customer_contacts SET '{$_SESSION['type']}' = '{$_POST['amount']}'
WHERE Company_Name = '{$_SESSION['comp_name']}'";
The problem is after the SET command, I need the field I'm setting to be a variable earlier defined. If I echo the $_SESSION['type'] before I execute the query the data looks correct. However, when I run the query I get a bad query return. I can also replace the variable with the actual name of the field and it works. But I need it to be dynamic. Any thoughts?
My query code is this:
$query_fee = "UPDATE customer_contacts SET '{$_SESSION['type']}' = '{$_POST['amount']}'
WHERE Company_Name = '{$_SESSION['comp_name']}'";
The problem is after the SET command, I need the field I'm setting to be a variable earlier defined. If I echo the $_SESSION['type'] before I execute the query the data looks correct. However, when I run the query I get a bad query return. I can also replace the variable with the actual name of the field and it works. But I need it to be dynamic. Any thoughts?