I have been working on this project for a couple days now and am stuck. I am getting the following error in my code:
Error: 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 '\n", "%' OR STYLE_NUM LIKE '%", $extra_styles )."%'"; , //$extra_styles_sql=" OR' at line 4
This code appears on my database.php file which looks like this:
Code: Select all
<?php
include "./connect_test.php";
include "./functions_test.php";
?>
<?php
//Pull in some additional styles
$extra_styles=file_get_contents("./extra_styles.txt");
$extra_styles_sql=" OR STYLE_NUM LIKE '%".str_replace( "\n", "%' OR STYLE_NUM LIKE '%", $extra_styles )."%'";
//$extra_styles_sql=" OR STYLE_NUM LIKE '%"%' OR STYLE_NUM LIKE '%%'";
$custom_order_string="Charms & More,Necklaces,Bracelets";
$sql=
'SELECT
webstyle.STYLE_NUM,
webcategory.DESCRIPTION,
IF( FIND_IN_SET( webcategory.DESCRIPTION, "'.$custom_order_string.'" )!=0, FIND_IN_SET( webcategory.DESCRIPTION, "'.$custom_order_string.'" ), 99 ) AS custom_order
FROM webstyle
JOIN webcategory ON webstyle.CATEGORY=webcategory.CATEGORY_CODE
WHERE
(webstyle.WEB_SUB_CATEGORY LIKE "Charm>%" OR webstyle.WEB_SUB_CATEGORY LIKE "Spacers>%" OR webstyle.WEB_SUB_CATEGORY LIKE "Base>%" '.$extra_styles_sql.' OR webstyle.COLLECTION="BR ABC\'S" )
AND SUBSTRING(webstyle.VIEW_ORDER_RETAIL, 1, 1) = "Y"
ORDER BY custom_order, WEB_SUB_CATEGORY DESC
';
$style_numbers=get_table_data( $bright1_shopping_connection, $sql );
//Because the ordering involves a regular expression, it's more efficient to loop through the list of styles
/*
print "<pre>";
print_r($style_numbers);
print "</pre>";
*/
$code=implode( "\n", $style_numbers["webstyle.STYLE_NUM"] );
print $code;
?>Thanks,
Joe