[PHP-DB] No mysql_error() from mysql_connect() From: Christoph Ender (Christoph.Ender <email protected>)
Date: 12/28/00

Hi,

When trying to connect to a MySQL Database, I try catch errors with
mysql_error(). That works fine, but not for mysql_connect().

Example:

------------------------------------------------------------------------
<?php
$linkid = mysql_connect("localhost", "myusername", "mypassword");
echo mysql_errno().": ".mysql_error()."<BR>";
?>
------------------------------------------------------------------------

returns the following:

------------------------------------------------------------------------
Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (111) in
/usr/local/httpd/htdocs/ModernMarket/t1.php3 on line 3
:
------------------------------------------------------------------------

So just a single colon, no messages. Turning off the warnings like this...

------------------------------------------------------------------------
<?php
$old_error_reporting = error_reporting(E_ALL & ~(E_WARNING ));
  
$linkid = mysql_connect("localhost", "myusername", "mypassword");
echo mysql_errno().": ".mysql_error()."<BR>";

error_reporting($old_error_reporting);
?>
------------------------------------------------------------------------

... leaves me just with a colon. I can test for a valid database
connection with "if ($link) ..." but I'd like to catch the mysql error
that caused the connection-failure.

Any ideas? Someone succeeded here?

Thanks in advance,
Christoph.

-- 
Christoph Ender
chrender <email protected>
http://www.moondock.org/chrender/

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>