PDA

View Full Version : Php & Pear Db.php


rd42
10-3-03, 08:48 AM
I have a db_connect.php file in my root directory above htdocs and the PEAR directory in htdocs. I'm not getting any error other that DB: Connect Failed. I can write a simple script with no includes that will connect to the DB just fine, but for some reason the db_connect.php script below is failing. Any ideas?

<?php
//require the PEAR::DB classes.
require_once 'DB.php';

$db_engine = 'mysql';
$db_user = 'xxx';
$db_pass = 'xxxx';
$db_host = 'mysql0xx.powweb.com ';
$db_name = 'loser';
$datasource = $db_engine. '://'. $db_user. ':' . $db_pass . '@' . $db_host.'/' . $db_name;

$db_object = DB::connect($datasource, TRUE);

$db = DB::connect("mysql://$db_user:$db_pass@$db_host/$db_name");

/* assign database object in $db_object,
if the connection fails $db_object will contain
the error message. */
// If $db_object contains an error:
// error and exit.

if(DB::isError($db_object)) {
die($db_object->getMessage());
}
$db_object->setFetchMode(DB_FETCHMODE_ASSOC);
// we write this later on, ignore for now.
#include('check_login.php');
?>