I'm using a function that comes with one of the wordpress plugins to call price based on name of product.
The problem is the MySQL cannot read the smart quotes.
I found a bit of code, which is supposed to remove these smart quotes.
Code: Select all
function convert_smart_quotes($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151));
$replace = array("'",
"'",
'"',
'"',
'-');
return str_replace($search, $replace, $string);
} Code: Select all
$query = 'SELECT wp_wpsc_product_list.price FROM `wp_wpsc_product_list` WHERE wp_wpsc_product_list.name = "' . wpsc_the_product_title() . '"';
$query2 = convert_smart_quotes($query);Any ideas what I'm doing wrong?
Thanks,
Aravona