Q: PHP PDO Select statement not working New to mysql and VERY new to PDO - But am trying to learn with lots of tutorials.
I am trying to grab an entry in the database that corresponds to the users ID and then use that to echo out the username, etc on a profile page.
$stmt = $conn->query('SELECT * FROM clients WHERE id = 42');
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

    // Content here...

echo $results['firstname'];

This is giving me an error that the firstname is undefined - what am I doing wrong here?
Working off this tutorial: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

A: Try to change it with:
$results = $stmt->fetch(PDO::FETCH_ASSOC)

as your are requesting a single row from your database and not an array with rows
PDOStatement::fetchAll — Returns an array containing all of the result set rows
PDOStatement::fetch — Fetches the next row from a result set

