Ok so Im trying to test my SLIM
PUT request that essentially updates a row in the database according to the ID
. Im currently testing curl commands via terminal on my computer before I can actually use them with user inputted data.
I've tried a million different CURL commands. e.g ->
curl -i -X PUT -d 'title=James is awesome!&date=2009-03-02' http://localhost/diploma/cloud_computing/ex4/article/1
curl -X PUT -d Title='Test' -d date='02-05-02' http://localhost/diploma/cloud_computing/ex4/article/1
curl -X PUT -d Title=Test -d date=02-05-02 http://localhost/diploma/cloud_computing/ex4/article/1
Here's my code (PHP + SLIM):
//Update the table. Pass is an ID primary key
$app->put(
'/article/:id',
function ($id) {
if(isset($_PUT['title'])){
$title = $_PUT['title'];
}
if(isset($_PUT['date'])){
$date = $_PUT['date'];
}
$sqlStr = "UPDATE articles SET title = '$title', date = '$date' WHERE id = $id";
try {
//Use our getConnection function
$db = getConnection();
$stmt=$db->prepare($sql);
$stmt->execute();
//Close the db connection
$db = null;
} catch (PDOException $e) {
echo $e->getMessage();
}
}
);