Date: 12/28/00
- Next message: john slee: "Re: [PHP-DB] 'Best' DB for Linux/Apache/PHP?"
- Previous message: JJeffman: "Re: [PHP-DB] FastTemplates and MySQL data?"
- Next in thread: Paul DuBois: "Re: [PHP-DB] No mysql_error() from mysql_connect()"
- Reply: Paul DuBois: "Re: [PHP-DB] No mysql_error() from mysql_connect()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
- Next message: john slee: "Re: [PHP-DB] 'Best' DB for Linux/Apache/PHP?"
- Previous message: JJeffman: "Re: [PHP-DB] FastTemplates and MySQL data?"
- Next in thread: Paul DuBois: "Re: [PHP-DB] No mysql_error() from mysql_connect()"
- Reply: Paul DuBois: "Re: [PHP-DB] No mysql_error() from mysql_connect()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

