Unable to change two things about a single row in mysql with php

Posted by user1624005 on Stack Overflow See other posts from Stack Overflow or by user1624005
Published on 2012-10-30T04:56:49Z Indexed on 2012/10/30 5:00 UTC
Read the original article Hit count: 65

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql