This topic is locked
[SOLVED]

 Where is my error ?

5/20/2012 10:35:41 PM
PHPRunner General questions
J
joiresende author

Where is the mistake?

Use the code below to update another table and always gives error. Where I could be wrong.
CustomQuery("Update table2 set quantity = quantity - ".$values["quantity"]."

where id = ".$values["id"]);

D
danaci 5/21/2012

CustomQuery("Update table2 set quantity = quantity - ".'$values["quantity"]'." where id = ".'$values["id"]');

J
joiresende author 5/21/2012

Unfortunately still gives syntax error

D
danaci 5/21/2012

$sql = ("SELECT quantity FROM table2 WHERE your_condition");
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
$temp_var=$data["quantity"];
CustomQuery("Update table2 set quantity =". '$temp_var'. "-". '$values["quantity"]'." where id = ".$values["id"]);

Sergey Kornilov admin 5/21/2012

As a typical suggestion print your SQL Query on the page instead of executing it. This way you can see what causes the syntax error.
More info an examples at http://xlinesoft.com/phprunner/docs/debugging_tips.htm

S
stiven 5/21/2012

CustomQuery("Update table2 set quantity = quantity - ".$values['quantity']."

where id = '".$values['id']."'");
J
joiresende author 5/21/2012

Stivens

thank you

It worked perfect