RE: [PHP] Problem connecting to MySQL with PEAR::DB and mysqli

2005-02-18 Thread Denis Gerasimov

Hello,

I suspect that all is OK in your code. I had a very similar problem three
days ago. Try connecting to FQDN like [EMAIL PROTECTED] via TCP/IP, not to
localhost via UNIX socket. It works in my case at least.

BTW it seems to be a DB package bug... write a simple test script with
mysqli_* functions and look if it will work.

And, of course, check MySQL user priviliges/hosts twice!

Best regards, Denis Gerasimov
Outsourcing Services Manager,
VEKOS, Ltd.
www.vekos.ru


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 17, 2005 11:47 AM
 To: php-general@lists.php.net
 Subject: [PHP] Problem connecting to MySQL with PEAR::DB and mysqli
 
 hello
 
 
 when connecting to MySQL 4.1 using PHP 5 and PEAR::DB I get this error:
 
 DB Error: connect failed
 
 a closer look gets this:
 
 Can't connect to local MySQL server through socket 'localhost' (2)
 
 the code for the connection is like this::
 
 
 public static function getConnection() {
 $mysql_user=myname;
 $mysql_password=secret;
 $mysql_host=localhost;
  $db_name=mydb;
  $dsn=mysqli://$mysql_user:[EMAIL PROTECTED]/$db_name;
 echo$dsn;
 $db=DB::connect($dsn);
 if(DB::isError($db)){
 echo$db-getMessage();
 }
 return$db;
 }
 ===
 
 the DSN looks correct:
 and in the php.ini I set the following option:
 
 mysqli.default_socket = /var/lib/mysql/mysql.sock
 
 this is where the socket for mysql access is.
 then I restarted apache and mysqld.
 
 the MySQL Server is running. I can connect via mysql on the command line
 but not with PEAR::DB.
 
 I am using PHP 5, the latest PEAR::DB, Apache 1.3 on a Redhat 7.3 System.
 
 any ideas what's wrong here ?
 
 Markus
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem connecting to MySQL with PEAR::DB and mysqli

2005-02-17 Thread Richard Lynch
[EMAIL PROTECTED] wrote:
 when connecting to MySQL 4.1 using PHP 5 and PEAR::DB I get this error:

 DB Error: connect failed

 a closer look gets this:

 Can't connect to local MySQL server through socket 'localhost' (2)

 the code for the connection is like this::

 
 public static function getConnection() {
$mysql_user = myname;
$mysql_password = secret;
$mysql_host = localhost;
$db_name = mydb;
$dsn = mysqli://$mysql_user:[EMAIL PROTECTED]/$db_name;
echo $dsn;
$db = DB::connect($dsn);
if(DB::isError($db)) {
   echo $db-getMessage();
}
return $db;
 }
 ===

 the DSN looks correct:
 and in the php.ini I set the following option:

 mysqli.default_socket = /var/lib/mysql/mysql.sock

 this is where the socket for mysql access is.
 then I restarted apache and mysqld.

 the MySQL Server is running. I can connect via mysql on the command line
 but not with PEAR::DB.

 I am using PHP 5, the latest PEAR::DB, Apache 1.3 on a Redhat 7.3 System.

You could try using ODBC to connect to the DSN, I think, and maybe see if
it's the DSN itself that is messed up...

Assuming that DSN means the same thing in 'DB' as it does in 'ODBC', which
may be a completely invalid assumption on my part...

Perhaps try changing 'localhost' to '127.0.0.1' in case your DNS and
/etc/hosts are messed up somehow.

I suppose you could even try changing localhost to
'/var/lib/mysql/mysql.sock' -- not that I think it will work, but it's the
kind of desparation thing I always try, and end up learning something
from. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php