-
HELP! Cannot connect to MySQL with MDB2
I get an error when trying to connect to mydb. I know the login and password work
Here is my code that does not work;
require_once '/usr/local/php52/pear/MDB2.php';
global $mdb2;
$dsn = array(
'phptype' => 'mysql',
'username' => 'root',
'password' => 'password',
'hostspec' => 'localhost:3306',
'database' => 'mydb',
);
$options = array ( 'persistent' => false
);
$mdb2 =& MDB2::connect($dsn, $options);
if (PEAR::isError($mdb2)) {
die($mdb2->getMessage());
}
echo '<br />mdb2='. $mdb2 . '<br />';
$mdb2->loadModule('Extended');
$mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC);
Here is my result:
MDB2 Error: connect failed
As a test I made the code:
$host = "localhost:3306";
$user="root";
$password="password";
$database="mydb";
$dbc = mysql_connect($host,$user,$password);
and I connect.
-
Unfortunately this error is not very descriptive and I cannot tell you the exact reason. Also, I am not quite acquainted with MDB2 connect method but I see there are some debugging options available which you should consider such as:
$options = array(
'debug' => 2,
'portability' => MDB2_PORTABILITY_ALL,
);
Please check for more info:
http://pear.php.net/manual/en/packag...ro-connect.php
Similar Threads
-
By jrossUCM in forum Hosting Related Questions
Replies: 2
Last Post: 08-07-2010, 04:34 AM
-
By stocknin in forum General Joomla Discussions
Replies: 1
Last Post: 11-16-2009, 05:50 AM
-
By robisaks in forum Hosting Related Questions
Replies: 1
Last Post: 10-08-2009, 08:06 AM
-
By adeibiza in forum Other Software and Applications
Replies: 2
Last Post: 04-07-2008, 09:26 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Copyright © 2012 SiteGround.com Inc