1

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?

4

2 に答える 2

3

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.

于 2012-10-18T21:29:51.147 に答える
0

'UPDATE stateCarriers SET `'.$entry.'`= 1 WHERE cname="'.$cname.'" AND zone="'.$zoneName.'"'

于 2012-10-18T21:32:25.887 に答える