1

I am getting an SQl syntax error when running the following query and can not see what is wrong with it:

$query = "UPDATE combined SET v_categories_name_1_1='Hoodie', 
v_attribute_options_id_1=1, v_attribute_values_id_1_1=1, v_attribute_values_id_1_2=2, 
v_attribute_values_id_1_3=3, v_attribute_values_id_1_4=4, 
v_attribute_values_price_1_1=0, v_attribute_values_price_1_2=0, 
v_attribute_values_price_1_3=0, v_attribute_values_price_1_4=0, 
v_attribute_options_name_1_1='Size', v_attribute_values_name_1_1_1='Small', 
v_attribute_values_name_1_2_1='Medium', v_attribute_values_name_1_3_1='Large', 
v_attribute_values_name_1_4_1='Extra Large') " .
"WHERE v_products_model='$fileName'";

And here is the 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 ') WHERE v_products_model=hs_3stm_giantsk.jpg' at line 1

UPDATE:

Thanks everyone for the super fast replies, it's solved my problem though unfortunately I can't accept them for another 9 minutes!

1
  • If you find any of the answers helpful, please accept it as the correct answer so this question can be marked as resolved. If you still have issues with it, I would love to assist. Thanks! Commented Jun 28, 2012 at 0:15

6 Answers 6

3

Try formatting your queries; problems become much more apparent:

$query = "
    UPDATE combined SET 
        v_categories_name_1_1='Hoodie', 
        v_attribute_options_id_1=1,
        v_attribute_values_id_1_1=1,
        v_attribute_values_id_1_2=2, 
        v_attribute_values_id_1_3=3, 
        v_attribute_values_id_1_4=4, 
        v_attribute_values_price_1_1=0, 
        v_attribute_values_price_1_2=0, 
        v_attribute_values_price_1_3=0,
        v_attribute_values_price_1_4=0, 
        v_attribute_options_name_1_1='Size',
        v_attribute_values_name_1_1_1='Small', 
        v_attribute_values_name_1_2_1='Medium', 
        v_attribute_values_name_1_3_1='Large', 
        v_attribute_values_name_1_4_1='Extra Large')
    WHERE v_products_model='$fileName'
";

That bad paren is much easier to notice when you're not just looking at one big blob of text. You would (hopefully) never write PHP like that, so why write your SQL like that?

Sign up to request clarification or add additional context in comments.

Comments

2

You close parens that you you never open.

Comments

2

You have an odd ) at the end of the line before the last.

Comments

2

There is a symbol ) appearing for no reason :)

Comments

2

Try this

$query = "UPDATE combined SET v_categories_name_1_1='Hoodie', 
v_attribute_options_id_1=1, v_attribute_values_id_1_1=1, v_attribute_values_id_1_2=2, 
v_attribute_values_id_1_3=3, v_attribute_values_id_1_4=4, 
v_attribute_values_price_1_1=0, v_attribute_values_price_1_2=0, 
v_attribute_values_price_1_3=0, v_attribute_values_price_1_4=0, 
v_attribute_options_name_1_1='Size', v_attribute_values_name_1_1_1='Small', 
v_attribute_values_name_1_2_1='Medium', v_attribute_values_name_1_3_1='Large', 
v_attribute_values_name_1_4_1='Extra Large' " .
"WHERE v_products_model='$fileName'";

I removed the bracket before WHERE clause.

Comments

2

Enclosing bracket with no opening one here

='Extra Large')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.