note 103689 deleted from function.mysql-error by danbrown
| From: | danbrown@php.net | Date: | Thu, 28 Apr 2011 15:09:52 +0000 |
| Subject: | note 103689 deleted from function.mysql-error by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179233@lists.php.net to get a copy of this message | ||
Note Submitter: Andy
----
One annoying feature of mysql_error() is its inability to return connection errors when you have
multiple connections.
e.g.:
<?php
$db1 = mysql_connect($a, $b, $c); // valid details
$result = mysql_query("SELECT 'Hello World'");
$db2 = mysql_connect($d, $e, $f); // invalid details
if (!$db2) {
echo mysql_error(); // if you don't supply any link identifier it will use the last valid
one, in this case $db1, which returns blank.
echo mysql_error($db2); // errors because $db2 is a boolean with the value FALSE, not a link
identifier.
}
?>