Unable to change two things about a single row in mysql with php
- by user1624005
Here's the code:
$id = intval($_POST['id']);
$score = "'" . $_POST['score'] . "'";
$shares = "'" . $_POST['shares'] . "'";
$conn = new PDO('mysql:host=localhost;dbname=news', 'root', '');
$stmt = $conn->prepare("UPDATE news SET 'shares' = :shares, 'score' = :score
WHERE id = :id");
$stmt -> execute(array(
'shares' => $shares,
'score' => $score,
'id' => $id
));
And it doesn't work. I am unsure as to how I would see the error that I assume mysql is giving somewhere, and I've tried everything I could think of.
Using double quotes and adding the variables into the statement right away.
Adding single quotes to shares and score.
How am I supposed to be doing this?