Pear MDB2 connection problems. All help appreciated

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
supergrover1981
Forum Newbie
Posts: 11
Joined: Sun Nov 26, 2006 6:36 am

Pear MDB2 connection problems. All help appreciated

Post by supergrover1981 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi Guys,

I've been using pear on my local machine for the last two weeks or so without any problems - I've just tried to migrate some stuff to a remote (shared) server for the first time, and I'm having a bit of a problem.

I'm trying to connect via MDB2, using the following:

Code: Select all

$connection = MDB2::connect("mysql://$db_username:$db_password@$db_host/$db_database");
        if (MDB2::isError($connection)) {
        die ("Could not connect to the database: <br />".MDB2::errorMessage($connection));
    }
    ?>

which is always met with the dreaded: "Could not connect to the database: not found" error.

However:

- I can connect using the same login details via the non-pear mysql_connect call
- I can connect via MDB2 on my local machine using the same mdb2 code
- I've looked via pear remote-list and MDB2 is installed on the remote machine

Any suggestions would be really, truly appreciated - I'm quite stumped. Connection code attached below. :-)

Many thanks,
- JB

Code: Select all

php:$db_username='tempscou_testconn';
    $db_password='conntest';
    $db_host='localhost';
    $db_database='tempscou_jts';

    require_once('MDB2.php');

    $connection = MDB2::connect("mysql://$db_username:$db_password@$db_host/$db_database");
        if (MDB2::isError($connection)) {
        die ("FROG1Could not connect to the database: <br />".MDB2::errorMessage($connection));
    }
    ?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

if (MDB2::isError($connection)) {
	$msg = "FROG1Could not connect to the database: <br />".MDB2::errorMessage($connection);
	if ( isset($connection->userinfo) ) {
		$msg .= "<br />\n" . $connection->userinfo;
	}
	die ($msg);
}
Probably the mysql driver for mdb2 is not present.
supergrover1981
Forum Newbie
Posts: 11
Joined: Sun Nov 26, 2006 6:36 am

Post by supergrover1981 »

*grin* Lots of thanks volka, you're right - MDB2_driver_mysql was not installed.

While we're on the topic, anyone have any suggestions for a solid shared-server webhost with either:

- SSH & the ability to install your own pear packages?
- The vast majority of pear packages installed as standard?

I've pretty much had to walk my web host through the process of installing PEAR + packages & they've messed it up a few times already. Any suggestions most appreciated. :-)

Cheers,
- JB
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Haved you noticed http://pear.php.net/manual/en/installation.shared.php
Installation of a local PEAR copy on a shared host
[...]
Installing a local copy of PEAR through ftp has become a piece of cake in PEAR 1.4.3+.
?
supergrover1981
Forum Newbie
Posts: 11
Joined: Sun Nov 26, 2006 6:36 am

Post by supergrover1981 »

*grin* Done - I can't believe I wasn't aware of this. :-)

Many thanks Volka - a tremendous help :-)
Post Reply