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?