Rich
Rich

Reputation: 512

Php site won't run, stops at the Pear DB connect, but no error

I've migrated a site to our hosting, standard ubuntu Plesk 11 server...

The site will not run, it stops at this line, with no error logged, or returned to the screen.

    $db=&DB::connect("mysql://$config[db_username]:$config[db_password]@$config[db_host]/$config[db_name]" );

The config array is populated with the correct info for the database. The next few lines of code are

if (PEAR::isError($db)) {
    print nl2br(var_export($db));
    die("Failed connecting to database");
}

Which the program never gets to? So I'm really stuck. It has the correct info, the database is there, but it does not appear to be able to get any further than the DB::connect line, but isn't showing any error?

Upvotes: 0

Views: 691

Answers (2)

Rich
Rich

Reputation: 512

Well the above didn't return anything either, but I did find that DB has been superceeded by MDB2, so I updated with

require_once('/usr/share/php/MDB2.php');

and

$db =&  MDB2::factory("mysql://$config[db_username]:$config[db_password]@$config[db_host]/$config[db_name]" );

Which did get me an error, saying PHP Fatal error: Call to undefined function: MDB2_Driver_mysql::getAll(). in /usr/share/php/MDB2.php on line 1936

So I added this

$db->loadModule('Extended');

From this question Fatal error: Call to undefined function: MDB2_Driver_MYSQL::getAll()

and it seems to have connected. Still not quite there but now I have something on the screen ! Thanks all.

Upvotes: 0

teo
teo

Reputation: 801

Try to add these lines inside your "if block" to find out the error reason:

echo 'Standard Message: ' . $db->getMessage() . "\n";
echo 'Standard Code: ' . $db->getCode() . "\n";

Print additional info:

echo 'DBMS/User Message: ' . $db->getUserInfo() . "\n";
echo 'DBMS/Debug Message: ' . $db->getDebugInfo() . "\n";

Look at this link: http://pear.php.net/manual/en/package.database.db.db-error.php

Upvotes: 1

Related Questions