Saturday 15 March 2014

php - PDO won't update my data in the database, why? -


I am trying to use my database of PDOs and it just will not work. I can select data without any hiccup, but updating will not work right now. I do not get any error messages, but there is no change in my database after executing the query.

This is my code, this method is part of a class, so the peda has been defined but I can modify the whole code here, important bits:

  public function Do ($ q, $ data) {{$ stmt = $ this- & gt; Pdo- & gt; Ready ($ q); $ Stmt- & gt; Execute ($ data); Back true; } Hold (PDOException $ E) {$ this-> Error = $ e-> GetMessage (); return false; }}  

and:

  $ question = new query (base64_decode ($ _ POST ['value']), $ _POST ['question'] $ _POST ['code'], $ _POST ['number'], $ _POST ['ANSWER1'], $ _POST ['ANSWER2'], $ _POST ['answer3'], $ _POST ['answer4'], $ _POST ['correct answer']); $ Array = [': qid' = & gt; $ Question-> Qid, ': question' = & gt; $ Question-> Question, ': Code' = & gt; $ Question-> Code, ': number' = & gt; $ Question-> Number, ': answer1' = & gt; $ Question-> Answer 1, ': Answer2' = & gt; $ Question-> Answer 2, ': Answer3' => $ Question-> Answer 3, ': Answer4' = & gt; $ Questions- & answer; 4; ': Correct_answer' = & gt; $ Question-> Right_arms # 9]; $ Q = 'update question SET question =: question and code =: code and number =: number and ANSWER_1 =: ANSWER1 and ANSWER_2 =: ANSWER2 and ANSWER_3 =: answer3 and answer_4 =: answer4 and correct_answer =: correct_answer where question_id =: QID '; $ Db- & gt; Query ('SET NAMES UTF8'); $ Db- & gt; Modify ($ q, $ array);  

Thanks!

Separate fields to update the update status, not with commas:

< Pre = $ q = 'updated question SET question =: question, code =: code, number =: number, answer_1 =: answer1, answer_2 =: answer2, answer_3 =: answer3, answer_4 =: answer 4, right_ answer = : Correct_answer WHERE question_id =: qid ';

No comments:

Post a Comment