Categories > TinyButStrong general >

OT: using ampersand (&) from _GET in an MySQL query

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: TomH
Date: 2010-01-24
Time: 16:46

OT: using ampersand (&) from _GET in an MySQL query

Sorry to go OT again, Googling hasn't helped on this one either...

I have Mysql data field "category" has the value "Red & White"
I have a _GET param "?cat=Red & White" being passed to my script to use in a query.

When I stuff the value of _GET['cat'] into an Mysql query, the _GET value is truncated at the '&' symbol - so the query statement becomes
"SELECT * FROM weblinks WHERE category = 'Red '

I just have not been able to figure out how to translate the _GET value into a char string that works in the MySQL query

Any ideas or tips would be appreciated,
TomH
By: TomH
Date: 2010-01-25
Time: 03:05

Re: OT: using ampersand (&) from _GET in an MySQL query

Thanks, but I've got it now...

FWIW, needed to do urlencode($cat) before creating the _GET string so that the _GET string became  ?cat=Red+&+White

The problem stemmed from the '&' in white space of
the _GET string was triggering the php arg_separator when processing the _GET string -and- Id rather not change the arg_separator ;)