I'm trying to do a MySQL query in PHP with some special characters. It seems to work if I run the query on my database with straight SQL:
SELECT SUM(quantity_ordered) FROM `shopping_cart`
WHERE `cart_number` = 10316027
AND `size` IN ('5¼" x 8¼"','5⅜" x 7¾"','4½" x 9½"')
The above query returns the expected result and SUM but when I put it in my prepared PHP query it returns no records or SUM.
I suspect that it has to do with the single quotes around each size but if I remove them I get a MySQL error. A similar query in my PHP with straight numbers and no surrounding quotes works fine.
I've tried different ways of escaping the special characters but I'm wondering if this query will work at all with these types of characters?
mysql_real_escape_stringfor `cart_number AND item_number.