In the code below, sessionId
is not getting updated in my database:
$stmt = $dbh->prepare("UPDATE user SET attempts = 0, sessionId = :sid WHERE userName = :postUser");
$stmt->bindParam(':postUser', $postUser);
$stmt->bindParam(':sessionId', $sid);
$stmt->execute();
I'm not getting any errors. I'm not too good with SQL, so i'm unsure if this is even valid syntax.
attempts
updates as it should. Why isn't sessionId
getting updated?
Your prepared statement uses :sid
, but you're binding a parameter named :sessionId
.
When working with PDO, I typically turn errors into Exceptions:
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
... It helps me catch syntax errors, etc.