Jump to content

Error: You have an error in your SQL syntax


jboku

Recommended Posts

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?

 

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

 

:/

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.