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 trialStephen Limmex
32,604 PointsNot Found The requested URL /inc/connection.php was not found on this server.
I am getting the below error message when attempting to duplicate the video:
Here is what I have entered in the address bar:
http://localhost/inc/connection.php
This is the error I receive:
Not Found
The requested URL /inc/connection.php was not found on this server.
My code is as follows:
<?php
$db = new PDO("sqlite:".DIR."/database.db");
var_dump ($db);
?>
Please advise.
Thank you, Steve
2 Answers
Damion Armentrout
39 PointsIt looks like this:
$db = new PDO("sqlite:".DIR."/database.db");
should be this:
$db = new PDO("sqlite:".__DIR__."/database.db");
The magic constant has two underscores before and after it.
Seth Johnson
15,200 PointsI'm having the same problem except I'm working from a localhost in MAMP. The "index" and "suggest" pages have previewed with no problems, but I get the NOT FOUND 404 error every time I try to preview "connection.php." If anyone can help me figure out what's going on, that would be awesome! I'm using a Mac and Chrome.
As an addendum, the document root I currently have set up in my MAMP settings is as follows: HD --> Applications --> MAMP --> htdocs --> siteBuild_002 (this is the name of my project folder but the files/file structure are exact duplicates of the project downloads).
Noam Modai
12,127 PointsNoam Modai
12,127 PointsIt seems like the problem is NOT in your code but rather that the "connection.php" file is not in the location specified by your URL and the server can therefore not find it.
Do you reach the index page by going to the url "localhost" (without anything else), if not have you installed your local server? (Alena gives all the explanation for MAMP so you can try that one)
It might also be that your server's homepage is not currently directing to you website folder. If you use MAMP go to MAMP preferences -> Web Server -> Select your websites directory (The folder containing the "inc" folder)
Finally, perhaps the port used by your server is not the right one. Try to look for the port option in your server and changing it to "80" and then go to this URL.