1

I have an issue with syntax in a query

This works

$db->execute_query("UPDATE table SET order=2,active_status=3 WHERE id=? AND uid=?",array($id,$uid));

But this does not. It's because of the array

$db->execute_query("UPDATE table SET order=?,active_status=3 WHERE id=? AND uid=?",array($shoid,$id,$uid));

I also tried something like

$db->execute_query("UPDATE table (`order`) WHERE id=? AND uid=? VALUES (?)",array($id,$uid,$shoid));

But this is not working either.

The error I get is this

Query failed : UPDATE orsil_quote (`order`) WHERE id='38' AND uid='115' VALUES ('49')

The problem is '49' if i can remove ' from 49 in the query. this will work like this , im sure

$db->execute_query("UPDATE table SET order=?,active_status=3 WHERE id=? AND uid=?",array($shoid,$id,$uid));
3
  • Post your full php Code Commented Jan 9, 2014 at 6:17
  • it is a lot of code, and most of it useless, if you want to know what does $shoid has, its just like $shoid='40' (the last id) i will edit to paste the error, throw so you can see Commented Jan 9, 2014 at 6:19
  • thanks :) that was what i meant (sorry for the sort comentary, i was on the mobile) Commented Jan 9, 2014 at 7:05

2 Answers 2

1

Your second query didn't worked because of the order keyword rest queries are not correct, like update query doesn't take VALUES i.e. used in your third query.

TRY

 db->execute_query("UPDATE table SET `order`=?,active_status=3 WHERE id=? AND  
                   uid=?",array($shoid,$id,$uid))
Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

UPDATE `table` SET `order`=2,active_status=3 WHERE (id, uid) IN (?)

Generate the pairs of (id, uid) like (id1, uid1), (id1, uid2), (id2, uid3), etc... and pass it to query.

2 Comments

order is a variable number sent in the array as $shoid, check the question again
@MonchoChavez Then you have to fire multiple query for each set of values

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.