Is there any way to pass &
symbol inside MySQl query with PHP?
I need to select values from database based on categories name, but category names may contains &
symbol
example: CATEGORY_TITLE=FRUITS & VEGETABLES
Is there any way to pass &
symbol inside MySQl query with PHP?
I need to select values from database based on categories name, but category names may contains &
symbol
example: CATEGORY_TITLE=FRUITS & VEGETABLES
I suspect you have problem on the transmission of variables (used by some javascript code). If that is true, then make sure that the parameters you pass in the query string use the encodeURIComponent method before.
That happens because &
has a special meaning (in fact it is a delimiter).
MySQL accepts &
as string without any problem.
There are a number of way to do it.
Before saving my data into DB, I use:
htmlentities($_POST['CATEGORY_TITLE'])
And on retrieval I use:
html_entity_decode($result['CATEGORY_TITLE'])