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.

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

<?php

try {
    $db = new PDO("mysql:host=localhost; dbname=shirts4mike; port=3306", "root", "root");
var_dump($db);
} 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
localhost
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
STAFF
andi mitre
Treehouse Guest Teacher

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