Connecting to MySQL Database from PHP
Posted: Tue May 31, 2005 7:20 am
I know this is a cheesy question. I just started learning PHP and MySQL and I cant get it to connect.
Here's the code Im using:
This is how one of the PHP tutorials tells me to connect. What is wrong here?
I get this on the browser:
DB Error: connect failed
I am using PHP 4.3.11 and MySQL 4.1
I tried to figure all acceptable dsn combinations and none of them work
Some help anybody please?
thanks,
tim
Here's the code Im using:
Code: Select all
<?php
require_once('DB.php');
// database connection setup section, user:pass@localhost/database
$dsn = "mysql://root:kujta21@localhost/timh";
// establish the connection
$db = DB::connect($dsn);
if (DB::isError($db)) {
die ($db->getMessage( ));
}
?>I get this on the browser:
DB Error: connect failed
I am using PHP 4.3.11 and MySQL 4.1
I tried to figure all acceptable dsn combinations and none of them work
Some help anybody please?
thanks,
tim