Forum Moderators: coopster

Message Too Old, No Replies

Replace & from a query string

         

cbadouin

5:25 pm on Jan 20, 2009 (gmt 0)

10+ Year Member



I have a field (BusinessName) that has data that contains an "&" Such as Deli & Bakery, Tile & Stone.

How do you, when querying the data, replace an existing & with & for proper output for XML?

Cheers,
Chris

bkeep

5:32 pm on Jan 20, 2009 (gmt 0)

10+ Year Member



use str_replace

I check for valid markup first and change it to a regular & then convert it back to the valid markup helps with consistency


$BusinessName = str_replace('&', '&', $BusinessName);
$BusinessName = str_replace('&', '&', $BusinessName);

Regards,
Brandon

cbadouin

11:06 pm on Jan 20, 2009 (gmt 0)

10+ Year Member



Sorry I am new to PHP......

Where you place that in regards to a query?

coopster

11:31 pm on Jan 21, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, cbadouin.

bkeep is talking about after you have run the query and are processing the result set. You run the code on your string variable that you fetched from your database result set.