No mysql_error() from mysql_connect()
| From: | Christoph Ender | Date: | Thu, 28 Dec 2000 22:46:39 +0000 |
| Subject: | No mysql_error() from mysql_connect() | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-5497@lists.php.net to get a copy of this message | ||
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@moondock.org
http://www.moondock.org/chrender/