Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKen Chung
17,585 PointsWhat's wrong with my code?
Hi everyone,
I'm currently working PHP & Databases with PDO but I'm not working with workspaces, instead I'm working through it on windows (downloaded the project files). When I open index.php with chrome I get no output, all I get is literally the code I typed up.
<?php
// Remove before flight
ini_set('display_errors', 'On');
try {
$db = new PDO('sqlite:./database.db');
var_dump($db);
die();
} catch(Exception $e) {
echo $e->getMessage();
die();
}
?>
This is exactly what I see on google chrome.
file:///C:/Users/Kendrix/Desktop/PHP%20&%20Databases%20with%20PDO/index.php
This is my link running straight from the browser. Is this because php code needs to work with a hosted server?
2 Answers
Kristian Terziev
28,449 PointsHello Kendrick,
Yes php needs a server to run. You can use software such as xampp to create one on your local environment. Here is a video on how on install it:
Best, Kristiyan
Ted Sumner
Courses Plus Student 17,967 PointsI recommend XAMPP for Linux and Windows. I have not tried it on a Mac, but it works very well. Yes, you absolutely need a local server to try any PHP code on your computer.
Chyno Deluxe
16,936 PointsChyno Deluxe
16,936 Points//Fixed Code Presentation How to post Code