So three things:
- If you print the results of
get_loaded_extensions()
, you'll see
that pdo turns up as 'PDO', but you're looking for 'pdo' -- so the
result of your first if() is FALSE.
Yup. Confusing that the base extension is PDO, but the drivers are
lowercase like pdo_mysql for example. I see what's going on now.
- You then try loading pdo.so again, but it's already loaded by
php.ini, therefore you get the Warning and your own error message.
Yup. :)
- You plan on connecting to MySQL, but don't appear to have loaded
pdo_mysql.so anywhere. So you need to fix that.
I didn't realize I had to build pdo_mysql.so seperately. Thanks. In
the manual where it says "The following drivers currently implement
the PDO interface:" made me thing I got them all when I built PDO.
Now that I got all that worked out MySQL refuses my dsn string:
Connection failed: SQLSTATE[HY000] [2003] Can't connect to MySQL
server on '127.0.0.1' (111)
I can connect using this user and password using the mysql command
line client with no problems. I have other PHP scripts connecting
successfully with this user as well. See any problems with this code?
$dsn = 'mysql:host=127.0.0.1;dbname=test';
$user = 'root';
$password = 'changeme';
try
{
$dbh = new PDO( $dsn, $user, $password );
}
catch( PDOException $e )
{
echo 'Connection failed: ' . $e->getMessage() . "\n";
}
My MySQL user works otherwise:
mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.0.24
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Thanks,
--
Greg Donald
Zend Certified Engineer
http://destiney.com/