Reputation: 13
I have this table with 50 something fields each field contains the corresponding two character state name. I have this mysql_query when a state is selected
//$entry is state name abbr. Oregon = OR<br/>
//$cname and $zoneName aren't important.
'UPDATE stateCarriers SET '.$entry.'= 1 WHERE cname="'.$cname.'" AND zone="'.$zoneName.'"'
so I'm having an issue when OR
is the $entry
since mysql thinks it is the OR
operator.
How do I solve this issue without changing the field name to something else?
Upvotes: 1
Views: 139
Reputation: 2471
Try using the backtick character, e.g. `field`=1 to delimit the field. This seems to work pretty well for me, although it was under slightly different circumstances.
Upvotes: 3
Reputation: 829
'UPDATE stateCarriers SET `'.$entry.'`= 1 WHERE cname="'.$cname.'" AND zone="'.$zoneName.'"'
Upvotes: 0