DB::connect and/or PEAR problem
Posted: 24. June 2008 04:24
I'm having trouble connecting to a MySQL database using PEAR's DB package. I'm using the following code, which is part of a tutorial in the book I'm using to learn PHP/MySQL:
The error I get when I run the code is:
I can connect to the database just fine using mysql_connect(); this happens only when I use PEAR.
I'm running xampp 1.6.6a, and I have Windows XP SP3. I looked through similar situations in the forum, and closest I could find was an MDB2 pathing issue, which wasn't similar enough for me to adapt the answer.
I'm very new at PHP, but I'll try my best with any help you can give me.
- Code: Select all
<?php
include('db_login.php');
require_once('DB.php');
$connection = DB::connect("mysql://$db_username:$db_password@db_host/$db_database");
if(DB::isError($connection)) {
die("Could not connect to the database: <br />".DB::errorMessage($connection));
}
?>
The error I get when I run the code is:
- Code: Select all
Could not connect to the database:
connect failed
I can connect to the database just fine using mysql_connect(); this happens only when I use PEAR.
I'm running xampp 1.6.6a, and I have Windows XP SP3. I looked through similar situations in the forum, and closest I could find was an MDB2 pathing issue, which wasn't similar enough for me to adapt the answer.
I'm very new at PHP, but I'll try my best with any help you can give me.