note 103689 added to function.mysql-error
| From: | Andy at osu1 dot php dot net | Date: | Thu, 28 Apr 2011 10:13:39 +0000 |
| Subject: | note 103689 added to function.mysql-error | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179222@lists.php.net to get a copy of this message | ||
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.
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 77.89.163.162
----
Manual Page -- http://www.php.net/manual/en/function.mysql-error.php
Edit -- https://master.php.net/note/edit/103689
Del: integrated -- https://master.php.net/note/delete/103689/integrated
Del: useless -- https://master.php.net/note/delete/103689/useless
Del: bad code -- https://master.php.net/note/delete/103689/bad+code
Del: spam -- https://master.php.net/note/delete/103689/spam
Del: non-english -- https://master.php.net/note/delete/103689/non-english
Del: in docs -- https://master.php.net/note/delete/103689/in+docs
Del: other reasons-- https://master.php.net/note/delete/103689
Reject -- https://master.php.net/note/reject/103689
Search -- https://master.php.net/manage/user-notes.php