php - QUERY ERROR, can't update query in DB -



php - QUERY ERROR, can't update query in DB -

today tried create update function rest web service slim framework. got problem. had stuck queries, because didn't work well.

this class include query

public function updateusercard($card_id, $user_id, $barcode) { $stmt = $this->conn->prepare("update user_cards uc, cards c set uc.barcode = ? uc.id = ? , uc.id = c.card_id , uc.user_id = ?"); if($stmt == false) { die($this->conn->error); } else { $stmt->bind_param("iis", $user_id, $card_id, $barcode); $stmt->execute(); $num_affected_rows = $stmt->affected_rows; $stmt->close(); homecoming $num_affected_rows > 0; } }

i tried update 'barcode' column new value. didn't work.

and code in index.php

$app->put('/cards/users/:id', 'authenticate', function($id) utilize ($app) { // check required params verifyrequiredparams(array('barcode')); global $user_id; $barcode = $app->request->put('barcode'); $db = new usercard(); $response = array(); // updating card $result = $db->updateusercard($user_id, $card_id, $barcode); if ($result) { // card updated $response["error"] = false; $response["message"] = "card updated successfully"; } else { // card failed update $response["error"] = true; $response["message"] = "card failed update. please seek again!"; } echorespnse(200, $response); });

the responses $response["message"] = "card failed update. please seek again!";

did wrote wrong code ? help guys :)

it seems have wrong order while passing parameters calling updateusercard.

your function updateusercard takes 2 parameters ($user_id, $barcode) , @ time of calling updateusercard passing barcode first , userid.

check line, $result = $db->updateusercard($barcode, $user_id);

php mysql web-services rest slim

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -