PHP PEAR not able to connect to DB

lozina

Lifer
Sep 10, 2001
11,709
8
81
I've been working on a PHP project on my laptop for a while now using PEAR to do database work and now I am trying to deploy it to a new machine.

I installed all the software: apache web server, php 5, mysql 5. then did the same exact changes to apache's http.conf and php's php.ini as i did on my laptop, and I think I installed all the right packages in PEAR including DB.

When I run my app I immediately get an error:

"Fatal error: Uncaught exception 'Exception' with message 'DB Error: not found' in C:\web\vaim\classes\Base.php:65 Stack trace: #0 [internal function]: pearErrorHandler(Object(DB_Error)) #1 C:\web\vaim\classes\PEAR.php(901): call_user_func('pearErrorHandle...', Object(DB_Error)) #2 C:\web\vaim\classes\DB.php(966): PEAR_Error->PEAR_Error('DB Error: not f...', -4, 16, 'pearErrorHandle...', 'Unable to inclu...') #3 C:\web\vaim\classes\PEAR.php(563): DB_Error->DB_Error(-4, 16, 'pearErrorHandle...', 'Unable to inclu...') #4 C:\web\vaim\classes\DB.php(543): PEAR::raiseError(NULL, -4, NULL, NULL, 'Unable to inclu...', 'DB_Error', true) #5 C:\web\vaim\classes\Base.php(78): DB::connect('mysql://root:ro...') #6 C:\web\vaim\classes\Base.php(129): db_connect() #7 C:\web\vaim\classes\Base.php(108): executeInsert('INSERT INTO LOG...', Array) #8 C:\web\vaim\classes\Base.php(163): dolog('unable to query...', 1) #9 C:\web\vaim\classes\Base.php(154): handleDbError('unable to query...', 'SELECT * FROM u...', Array, Object(Exception)) #10 C:\ in C:\web\vaim\classes\Base.php on line 65"

basically all it seems to be telling me is "DB Error: not found"

what exactly it cannot find, I am not sure...

I tried connecting to the same database using the regular php database code and it worked.

i.e. :

$username = "myusername";
$password = "mypassword";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
mysql_select_db('myschema');
print "Connected to MySQL";

it echoes the connected to mysql message so it works fine.

as opposed to my PEAR code:

$db_host = 'localhost';
$db_user = 'myusername';
$db_pass = 'mypassword';
$db_name = 'myschema';
$dsn = "mysql://$db_user:$db_pass@unix+$db_host/$db_name";
echo 'connecting...';
$db = DB::connect($dsn);
echo 'connected';

it only echoes "connecting" but never echoes "connected"- it fails right at the DB::connect call.

What could be going on? Why is PEAR failing what the regular DB code is succeeding at?
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
do a phpinfo() on both servers and compare them side by side (ctrl+f for PEAR)
 

Rip the Jacker

Diamond Member
Dec 29, 2004
5,415
1
76
I'm a novice, but shouldn't you be using more checks/conditionals? To see if it actually connected and if not, spit the error out? All you're doing is assigning variable/link reference to mysql and then echo'ing some crap afterwards...