Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011
    Posts
    2

    Unhappy 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.

  2. #2
    Join Date
    Apr 2007
    Posts
    366

    Default

    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

  1. Can I Connect MYSQL Through VS?
    By jrossUCM in forum Hosting Related Questions
    Replies: 2
    Last Post: 08-07-2010, 04:34 AM
  2. Cannot connect to mysql during install
    By stocknin in forum General Joomla Discussions
    Replies: 1
    Last Post: 11-16-2009, 05:50 AM
  3. cannot connect to MySQL 4.1+ using old authentication
    By robisaks in forum Hosting Related Questions
    Replies: 1
    Last Post: 10-08-2009, 08:06 AM
  4. can mysql connect to my wordpress db
    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
  •