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 trial

Development Tools Using PHP with MySQL Querying the Database with PHP Querying the Database

Angelos Bolovinos
Angelos Bolovinos
3,958 Points

Object not found!

Hi this is my code


try {
    $db = new PDO("mysql:host=localhost; dbname=shirts4mike; port=3306", "root", "root");
} catch (Exception $e) {
    echo "Could not connect to the database.";


echo "Woo-Hoo!";

And this is what i get when running localhost/database.php on my browser

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.
Error 404
Apache/2.4.12 (Win32) OpenSSL/1.0.1m PHP/5.5.27 

Hi Angelos Bolovinos, I've formatted your code to make it a little easier to read.

1 Answer

andi mitre
andi mitre
Treehouse Guest Teacher

DId you add your port number prior to /database.php?