"&" char within of a ID can make some strange behaviors in SELECT ?

I got a super standard select on a field ID (CategoryID) but I got a problem with some ID containing special chars.

SELECT CategoryID, Descrizione_Web
FROM categories
WHERE CategoryID = ‘{CategoryID}’
ORDER BY Descrizione_Web

In my case the ID is “PCBG_C&C”.
Due to the fact that only where there is & there are problems I suppose that it’s not possible.

How can I modify the SELECT to read all the ID with also the & inside ?? Now it seems that it try to read PCBG_C and then it do not find the category description.

Thanks

You could try to use the addslashes php function to escape the characters.

Hello Albert,
thanks, just to understand…
may I add the adslashes within the mysql query ?

WHERE CategoryID = adslashes( ‘{CategoryID}’ )

I don’t think that is possible …

No, you need to put this in the onvalidate event, or in the beforeinsert/update.
{myfield}=addslashes({myfield})

OK . Many thanks. I’ll try