function update_review($link, $user_id, $game_id, $rating, $title, $review) {
$sql = "UPDATE reviews SET rating = ?, title = ?, review = ? WHERE user_id = ? AND game_id = ?";
$stmt = $link->prepare($sql);
if ( !$stmt ) {
die("could not prepare statement: " . $link->errno . ", error: " . $link->error);
}
$stmt->bind_param("sssii", $rating, $title, $review, $user_id, $game_id);
if ( !$stmt ) {
die("could not bind params: " . $stmt->error);
}
if ( !$stmt->execute() ) {
die("couldn't execute statement");
}
}
function update_review2($link) {
$sql = "update reviews set rating = \"43\", title = \"test\", review = \"blah\" where user_id = \"5\" and game_id = \"1\"";
$stmt = $link->prepare($sql);
if ( !$stmt ) {
die("could not prepare statement: " . $link->errno . ", error: " . $link->error);
}
if ( !$stmt->execute() ) {
die("couldn't execute statement");
}
}
var_dump($review_data);
// output = array(5) { ["user_id"]=> int(5) ["game_id"]=> int(1) ["rating"]=> string(2) "43" ["title"]=> string(4) "test" ["review"]=> string(4) "blah" }
update_review($link, $review_data['rating'], $review_data['title'], $review_data['review'], $review_data['user_id'], $review_data['game_id']);
Going to be honest, done the usual uni student thing and left the assignment to last min and regretting it again... Anyways been trying to figure this out for a few hours now and i've come to a loss, ive made it work by not using prepared statements as you can see above in the update_review2 function however when using the prepared statements version update_review it does not affect any rows in the db. If anyone can offer a bit of help it will be greatly appreciated especially because the deadline is in 6 hours!