Welcome Guest, Not a member yet? Register   Sign In
Need some help with escaping quotes
#1

[eluser]nydeveloper[/eluser]
I know this should be simple, but no matter what modifications I make to the following line I still wind up with an unexpected T_CONSTANT_ENCAPSED_STRING error. What specific items need to escaped in order for this query to run as expected?

Quote:$query = $this->db->query('UPDATE recipes set recipe_order = ABS(REPLACE(SUBSTR(recipe_name, 1, POSITION(' ' IN recipe_name)-1),',','')) + recipe_cost where category_id = 1 AND location_id = '.$location_id.';');

Please note that this query works as expected when running the SQL directly.
#2

[eluser]Bankzilla[/eluser]
Try doing any query modifiers outside of the query itself.
Also what's up with the ";" in the query?
#3

[eluser]nydeveloper[/eluser]
Turned out to be a simple fix - double quotes rather than single quotes outside of the entire query string.




Theme © iAndrew 2016 - Forum software by © MyBB