Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

nicholasgryczewski
2,919 Pointsgetting an parse error for my var_dump
My error: Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ')' in /home/treehouse/workspace/inc/connection.php on line 16
My Code: <?php try { $db = new PDO("sqlite:".DIR."/database.db"); $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); } catch(Exception $e) { echo "unable to connect."; echo $e ->getMessage(); exit;} try{ $results = $db ->query("SELECT title, category, img FROM Media"); echo "Retrieved Results";
} catch (Exception $e) {echo "unable to retrieve results"; exit;}
var_dump(Sresults ->fetchAll(PDO::FETCH_ASSOC)); ?>
1 Answer

Benjamin Larson
34,055 PointsIt's likely caused because you have 3 instances where you have a space between a variable and the object operator (->).
$e ->getMessage
$db ->query
$results ->fetchAll
Try removing the space from those and see what results you get.
nicholasgryczewski
2,919 Pointsnicholasgryczewski
2,919 Pointsoh no i found it. It was the Sresults! I was using a capital s instead of $. XD