jboku Posted November 16, 2009 Share Posted November 16, 2009 Hey guys, So I am getting the following error: 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 )."%'"; , , $custom_order_string="' at line 4 That's found in my database.php file which looks like this: <?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 )."%'"; $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 ); $code=implode( "\n", $style_numbers["webstyle.STYLE_NUM"] ); print $code; ?> Can someone help me? Do I have a " or ' missing or am I using it wrong? Link to comment https://forums.phpfreaks.com/topic/181799-error-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
9three Posted November 16, 2009 Share Posted November 16, 2009 Your code: $extra_styles_sql=" OR STYLE_NUM LIKE '%".str_replace( "\n", "%' OR STYLE_NUM LIKE '%", $extra_styles )."%'"; Will look like this: $extra_styles_sql=" OR STYLE_NUM LIKE '%"%' OR STYLE_NUM LIKE '%%'"; Link to comment https://forums.phpfreaks.com/topic/181799-error-you-have-an-error-in-your-sql-syntax/#findComment-958792 Share on other sites More sharing options...
jboku Posted November 17, 2009 Author Share Posted November 17, 2009 Your code: $extra_styles_sql=" OR STYLE_NUM LIKE '%".str_replace( "\n", "%' OR STYLE_NUM LIKE '%", $extra_styles )."%'"; Will look like this: $extra_styles_sql=" OR STYLE_NUM LIKE '%"%' OR STYLE_NUM LIKE '%%'"; After changing: $extra_styles_sql=" OR STYLE_NUM LIKE '%".str_replace( "\n", "%' OR STYLE_NUM LIKE '%", $extra_styles )."%'"; to $extra_styles_sql=" OR STYLE_NUM LIKE '%"%' OR STYLE_NUM LIKE '%%'"; I get the same error but in a different spot: syntax to use near '; , , $custom_order_string="Charms & More,Necklaces,Bracelets"; , , $sql= , 'SE' at line 4 :/ Link to comment https://forums.phpfreaks.com/topic/181799-error-you-have-an-error-in-your-sql-syntax/#findComment-958805 Share on other sites More sharing options...
jboku Posted November 17, 2009 Author Share Posted November 17, 2009 Anyone have any additional insight on this? :/ Link to comment https://forums.phpfreaks.com/topic/181799-error-you-have-an-error-in-your-sql-syntax/#findComment-959253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.