lawrence_dev
asked on
Error Syntax Error 1064 .. UT8MB4 not working
I am getting an error that i cannot fix. I have changed the database to UT8MB4 and have used every script in my arsenal to fix the problem and still get the same error. Please advise how to fix.
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's 2-Handset Cordless Answering System is packed with features. There's a 50-name' at line 1' in /home/electronics/download .php:347 Stack trace: #0 /home/electronics/download .php(347): PDO->query('UPDATE `Do...') #1 {main} thrown in /home/electronics/download .php on line 347
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's 2-Handset Cordless Answering System is packed with features. There's a 50-name' at line 1' in /home/electronics/download
$query68 = $conn->query('SELECT DISTINCT Sku, Title, DescriptionBottom FROM `ProductScrape` WHERE Sku IN (SELECT VENDORSKU FROM Download)');
while ($row68 = $query68->fetch(PDO::FETCH_ASSOC))
{
$NewTitle = $row68['Title'];
$NewFullDesc = $row68['DescriptionBottom'];
//$NewFullDesc = w1250_to_utf8($NewFullDesc);
//$NewTitle = w1250_to_utf8($NewTitle);
$NewImage = $row68['Sku']."-0.jpg";
$Sku = $row68['Sku'];
$NewTitle = preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($NewTitle, ENT_COMPAT, 'UTF-8'));
$NewTitle = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'.
'|[\x00-\x7F][\x80-\xBF]+'.
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'.
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
'?', $NewTitle);
$NewTitle = preg_replace('#\\x[a-zA-Z0-9]{2}#i', ' ', $NewTitle);
$NewTitle = htmlspecialchars($NewTitle);
$NewFullDesc = preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($NewFullDesc, ENT_COMPAT, 'UTF-8'));
$NewFullDesc = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'.
'|[\x00-\x7F][\x80-\xBF]+'.
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'.
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
'?', $NewFullDesc);
$NewFullDesc = preg_replace('#\\x[a-zA-Z0-9]{2}#i', ' ', $NewFullDesc);
$NewFullDesc = htmlspecialchars($NewFullDesc);
//$NewFullDesc = preg_replace("/[^A-Za-z0-9 -]/", "", strip_tags(html_entity_decode(htmlspecialchars_decode(str_replace($strip," ",$NewFullDesc)))));
//$NewTitle = preg_replace("/[^A-Za-z0-9 -]/", "", strip_tags(html_entity_decode(htmlspecialchars_decode(str_replace($strip," ",$NewTitle)))));
//$NewFullDesc = htmlspecialchars($NewFullDesc, ENT_QUOTES);
//$NewTitle = htmlspecialchars($NewTitle, ENT_QUOTES);
$conn->query("UPDATE `Download` SET IMAGE = '$NewImage', LONGDESC = '$NewFullDesc', TITLE = '$NewTitle' WHERE SKU = '$Sku'");
}
ASKER
Update
use
mysqli_real_escape_string( )
ie
mysqli_real_escape_string(
ie
$NewFullDesc= mysqli_real_escape_string($NewFullDesc)
$conn->query("UPDATE `Download` SET IMAGE = '$NewImage', LONGDESC = '$NewFullDesc', TITLE = '$NewTitle' WHERE SKU = '$Sku'");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select or update?