PDO Fetch statement only retrieves first column

You can only select the id column because that is all you have in the query.

Try something like this

if (isset($_SESSION['id'])) {
    $presh = $_SESSION['id'];
    $stmt = $pdo->prepare("SELECT id, karmacurrent FROM users WHERE id = :id");

    $id = $presh;

    $stmt->execute(
        array(
            ':id'=>$id
        )
    );

    $accountinfo = $stmt->fetch(PDO::FETCH_ASSOC);
}

Basically you were only retrieving the ID from the table instead of the other columns.

Leave a Comment