Зов за помощ - едно момче ми направи един скрипт за ъпдейт на продуктите, но ми дава грешка при изпълението
Трябва да го чакам още една седмица да се освободи за да го оправи а ми е спешно, а съм сигурен, че е елементарна грешка -
Бихте ли ми помогнали?
Благодаря
Код:
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 '`='4'' at line 1
PHP:
<?phpob_start();set_time_limit(0);header('Content-type: text/html; charset=utf-8');ini_set("memory_limit","100000M");
require_once('../include/miphpf/Init.php'); require_once('../include/sc/Init.php'); scSession::singleton()->openSession();
$dir = 'productFiles'; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $openFile = file_get_contents(''.$dir.'/'.$file.''); $openFile = str_replace('product_id prod_id Quality URL supplier_id High_res_img Low_res_img Thumbnail_img UNCATID Category_ID m_prod_id ean_upcs model_name original_supplier_id product_view on_market country_market_set Updated', '', $openFile); if(!empty($openFile)) { $explode1 = explode("\n", $openFile);
foreach($explode1 as &$value) { $explode2 = explode(' ', $value); $PID = $explode2[0]; $PRID = $explode2[1]; $QUAL = $explode2[2]; $URL = $explode2[3]; $SQL = "SELECT * FROM `Products` WHERE `ProductCode`='$PRID'"; $RES = mysql_query($SQL) or die(mysql_error()); if(mysql_num_rows($RES) > 0) { $URLEN = ''.$URL.'shopname=tdaturl;lang=en'; $URLFR = ''.$URL.'shopname=tdaturl;lang=fr'; $tablestyle = '<style type="text/css"> td.ds_header { background: #D2E6FF; } td.footer { background: #D2E6FF; } .raised .b1 { background: #D2E6FF; } .raised .b2 { background: #D2E6FF; } .raised .b3 { background: #D2E6FF; } .raised .b4 { background: #D2E6FF; } .raised { width: 750; } td.ds_label {background: #CCCCCC;} td.price_label {background: #CCCCCC;} td.ds_data {background: #FFFFFF;} td.price_data {background: #FFFFFF;} td.image {background: #FFFFFF;} a.footer {color: #1450A0;} .link {color: #1450A0;} .vlink {color: #1450A0;} </style>'; //GET EN $NFOEN = @file_get_contents($URLEN); $NFOEN2 = eregi('<table align="center" cellpadding="0" cellspacing="0" class="mainTable">(.*)</table>', $NFOEN, $NFOEN3); $NFOEN10 = eregi('<p class="main">(.*)</td>', $NFOEN3[0], $NFOEN7); $NFOEN12 = explode('</td>', $NFOEN7[0]); $NFOEN14 = str_replace('<span id="long_desc_more">... <a class="more" style="font-size: 12px;font-weight: bold" href="javascript:show_more()">More>>></a></span><span id="more_text" style="display: none">', '', $NFOEN12[0]); $NFOEN14 = str_replace('<br></span><span style="display: none" id="long_desc_less"><a class="more" style="font-size: 12px;font-weight: bold" href="javascript:hide_more()"> <<<Less</span>', '', $NFOEN14); $NFOEN14 = str_replace('<p class="main">', '', $NFOEN14); $NFOEN14 = str_replacE('</p>', '', $NFOEN14); $NFOEN16 = eregi('<table cellpadding="4" cellspacing="0" width="100%">(.*)</table>', $NFOEN, $NFOEN9); $NFOEN18 = explode('<td colspan="2" style="padding: 0; text-align: center;">', $NFOEN9[0]); $NFOEN20 = eregi('<table cellpadding="4" cellspacing="0" width="100%">(.*)</table>', $NFOEN18[0], $NFOEN11); $NFOEN22 = str_replace("'", '', $NFOEN11[0]); $NFOEN24 = get_meta_tags($URLEN); //Values EN $informationEN = str_replace("'", '', $NFOEN14); $information2EN = str_replace("'", '', $NFOEN22); $information2EN = ''.$tablestyle.''.$information2EN.''; $productNameEN = str_replace("'", '', $NFOEN24['description']); //GET FR $NFOFR = @file_get_contents($URLFR); $NFOFR2 = eregi('<table align="center" cellpadding="0" cellspacing="0" class="mainTable">(.*)</table>', $NFOFR, $NFOFR3); $NFOFR10 = eregi('<p class="main">(.*)</td>', $NFOFR3[0], $NFOFR7); $NFOFR12 = explode('</td>', $NFOFR7[0]); $NFOFR14 = str_replace('<span id="long_desc_more">... <a class="more" style="font-size: 12px;font-weight: bold" href="javascript:show_more()">Tous>>></a></span><span id="more_text" style="display: none">', '', $NFOFR12[0]); $NFOFR14 = str_replace('<br></span><span style="display: none" id="long_desc_less"><a class="more" style="font-size: 12px;font-weight: bold" href="javascript:hide_more()"> <<<Moins</span>', '', $NFOFR14); $NFOFR14 = str_replace('<p class="main">', '', $NFOFR14); $NFOFR14 = str_replacE('</p>', '', $NFOFR14); $NFOFR16 = eregi('<table cellpadding="4" cellspacing="0" width="100%">(.*)</table>', $NFOFR, $NFOFR9); $NFOFR18 = explode('<td colspan="2" style="padding: 0; text-align: center;">', $NFOFR9[0]); $NFOFR20 = eregi('<table cellpadding="4" cellspacing="0" width="100%">(.*)</table>', $NFOFR18[0], $NFOFR11); $NFOFR22 = str_replace("'", '', $NFOFR11[0]); $NFOFR24 = get_meta_tags($URLFR);
//Values FR $informationFR = str_replace("'", '', $NFOFR14); $information2FR = str_replace("'", '', $NFOFR22); $information2FR = ''.$tablestyle.''.$information2FR.''; $productNameFR = str_replace("'", '', $NFOFR24['description']); //Get Image $NFOIMG = eregi('"javascript:openimage((.*),(.*),(.*))"', $NFOEN, $NFOIMG1); $NFOIMG2 = str_replace('javascript:openimage(', '', $NFOIMG1[0]); $NFOIMG2 = str_replace(')"', '', $NFOIMG2); $NFOIMG4 = explode(',', $NFOIMG2); $NFOIMG6 = $NFOIMG4[0]; $NFOIMG6 = str_replace('"', '', $NFOIMG6); $NFOIMG6 = str_replace("'", '', $NFOIMG6); list($width, $height, $type, $attr) = getimagesize($NFOIMG6); $IMGT = explode(',', $NFOIMG6); $IMGIN = count($IMGT) - 1; $IMGEX = $IMGT[$IMGIN]; $ROW = mysql_fetch_array($RES); $ProductID = $ROW['ProductID']; $SQL1 = "SELECT * FROM `ProductImages` WHERE `ProductID`='$ProductID'"; $RES1 = mysql_querY($SQL1) or die(mysql_error()); if(mysql_num_rows($RES1) > 0) { $ROW1 = mysql_fetch_array($RES1); $ProductImageID = $ROW1['ProductImageID']; $productIMG = 'userfiles/productimages/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG2 = 'userfiles/productthumbs/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG3 = 'userfiles/productlargeimages/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG4 = 'userfiles/productboximages/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG5 = 'userfiles/productimages/product_'.$ProductImageID.'.'.$IMGEX.''; @copy($NFOIMG6, '../'.$productIMG.''); @copy('../'.$productIMG.'', '../'.$productIMG2.''); @copy('../'.$productIMG.'', '../'.$productIMG3.''); @copy('../'.$productIMG.'', '../'.$productIMG4.''); @copy('../'.$productIMG.'', '../'.$productIMG5.''); $SQL2 = "UPDATE `ProductImages` SET `ProductImage`='$productIMG', `ProductImageWidth`='$width', `ProductImageHeight`='$height', `ProductImageSize`='1000', `ProductImageThumb`='$productIMG2', `ProductImageThumbWidth`='$width', `ProductImageThumbHeight`='$height', `ProductImageThumbSize`='1000', `ProductImageLarge`='$productIMG3', `ProductImageLargeWidth`='$width', `ProductImageLargeHeight`='$height', `ProductImageLargeSize`='1000', `ProductImageBox`='$productIMG4', `ProductImageBoxWidth`='$width', `ProductImageBoxHeight`='$height', `ProductImageBoxSize`='1000', `ProductImageOriginal`='$productIMG5' WHERE `ProductID`='$ProductID'"; $RES2 = mysql_query($SQL2) or die(mysql_error()); } else { $SQL2 = "INSERT INTO `ProductImages` (`ProductImageID`, `ProductID`) VALUES ('', '$ProductID');"; $RES2 = mysql_query($SQL2) or die(mysql_error()); $SQL3 = "SELECT * FROM `ProductImages` WHERE `ProductID`='$ProductID' ORDER BY `id` DESC LIMIT 1"; $RES3 = mysql_query($SQL3) or die(mysql_error()); $ROW3 = mysql_fetch_array($RES3); $ProductImageID = $ROW3['ProductImageID']; $productIMG = 'userfiles/productimages/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG2 = 'userfiles/productthumbs/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG3 = 'userfiles/productlargeimages/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG4 = 'userfiles/productboximages/product_'.$ProductImageID.'.'.$IMGEX.''; $productIMG5 = 'userfiles/productimages/product_'.$ProductImageID.'.'.$IMGEX.''; @copy($NFOIMG6, '../'.$productIMG.''); @copy('../'.$productIMG.'', '../'.$productIMG2.''); @copy('../'.$productIMG.'', '../'.$productIMG3.''); @copy('../'.$productIMG.'', '../'.$productIMG4.''); @copy('../'.$productIMG.'', '../'.$productIMG5.''); $SQL4 = "UPDATE `ProductImages` SET `ProductImage`='$productIMG', `ProductImageWidth`='$width', `ProductImageHeight`='$height', `ProductImageSize`='1000', `ProductImageThumb`='$productIMG2', `ProductImageThumbWidth`='$width', `ProductImageThumbHeight`='$height', `ProductImageThumbSize`='1000', `ProductImageLarge`='$productIMG3', `ProductImageLargeWidth`='$width', `ProductImageLargeHeight`='$height', `ProductImageLargeSize`='1000', `ProductImageBox`='$productIMG4', `ProductImageBoxWidth`='$width', `ProductImageBoxHeight`='$height', `ProductImageBoxSize`='1000', `ProductImageOriginal`='$productIMG5' WHERE `ProductID`='$ProductID'"; $RES4 = mysql_query($SQL4) or die(mysql_error()); } //EN UPDATE $SQL5 = "SELECT * FROM `ProductsML` WHERE `ProductID`='$ProductID' AND `LanguageID`='1'"; $RES5 = mysql_query($SQL5) or die(mysql_error()); if(mysql_num_rows($RES5) > 0) { $SQL6 = "UPDATE `ProductsML` SET `ProductDescription`='$informationEN', `ProductDetailedDescription`='$information2EN' WHERE `ProductID`='$ProductID' AND `LanguageID`='1'"; $RES6 = mysql_query($SQL6) or die(mysql_error()); } else { $SQL6 = "INSERT INTO `ProductsML` VALUES ('', '$ProductID', '1', '$productNameEN', '$informationEN', '$information2EN');"; $RES6 = mysql_query($SQL6) or die(mysql_error()); } //FR UPDATE $SQL7 = "SELECT * FROM `ProductsML` WHERE `ProductID`='$ProductID' AND `LanguageID`='4'"; $RES7 = mysql_query($SQL7) or die(mysql_error()); if(mysql_num_rows($RES7) > 0) { $SQL8 = "UPDATE `ProductsML` SET `ProductDescription`='$informationFR', `ProductDetailedDescription`='$information2FR' WHERE `ProductID`='$ProductID' AND LanguageID`='4'"; $RES8 = mysql_query($SQL8) or die(mysql_error()); } else { $SQL8 = "INSERT INTO `ProductsML` VALUES ('', '$ProductID', '1', '$productNameFR', '$informationFR', '$information2FR');"; $RES8 = mysql_query($SQL8) or die(mysql_error()); } } } } } } closedir($handle); } echo 'Successful Updated';?>
Трябва да го чакам още една седмица да се освободи за да го оправи а ми е спешно, а съм сигурен, че е елементарна грешка -
Бихте ли ми помогнали?
Благодаря
Последно редактирано: