php - Delete function works on localhost but not on Web -


i made function delete object in database. when test function, works on localhost, however, doesn't work on website. have idea how fix this? p.s: used slim

$app->delete('/places/:id', 'authenticate', function($place_id) use($app) {             global $user_id;              $db = new dbhandler();             $response = array();             $result = $db->deleteplace($user_id, $place_id);             if ($result) {                 $response["error"] = false;                 $response["message"] = "place deleted succesfully";             } else {                  $response["error"] = true;                 $response["message"] = "place failed delete. please try again!";             }             echorespnse(200, $response);         });  public function deleteplace($user_id, $place_id) {         $stmt = $this->conn->prepare("delete p places p, user_places p.id = ? , up.place_id = p.id , up.user_id = ?");         $stmt->bind_param("ii", $place_id, $user_id);         $stmt->execute();         $num_affected_rows = $stmt->affected_rows;         $stmt->close();         return $num_affected_rows > 0;     } 

delete p places p appears syntax error in sql.

$stmt = $this->conn->prepare(     "delete places p, user_places p.id = ? , up.place_id = p.id , up.user_id = ?" ); 

to avoid missing these errors in future, i'd suggest setting error mode pdo::errmode_exception:

$this->conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -