ID: 26114
User updated by: scouture at novo dot ca
Reported By: scouture at novo dot ca
Status: Bogus
Bug Type: MySQL related
Operating System: windows 2000
PHP Version: 4.3.3
New Comment:
Ok, I have redone my home work and recheck the docs for those two
functions. But, there is still something I don't understand in there
behavior.
If I try to open a link for the first time with
$test = mysql_connect ($ip, $user, $password, TRUE)
if($test == false)
{
echo mysql_errno();
}
if I enter a wrong user, I'll get the 1045 error, right ?
from docs
Note: If the optional argument is specified the given link is used to
retrieve the error code. If not, the last opened link is used.
In this case, I do not specify any link to mysql_errno so it should use
the last opened link, wich in this case, because it's the first time a
link is trying to be opened, do not exist. But, I can retrieve the
right errno anyway.
If I open a valid link, then try to reopened a second one using
$test2 = mysql_connect ($ip, $user, $password, TRUE)
if($test2 == false)
{
echo mysql_errno();
}
Has I understand, because there is already a valid link, mysql_errno()
use that link (because none is specified).
But, I have pass the parametre new_link set to TRUE, so those 2
functions should behave like there is no valid connection opened
before, like in the first time when I try to open a link and there is
none already opened and return me 1045.
If the new_link == FALSE, then they should use the last link opened but
in the case that new_link == TRUE, they should behave like there is no
other link opened.
I understand that this may not be a bug to you, but I'm sure you can
say that the behavior of the functions mysql_error() and mysql_errno()
(PHP 3, PHP 4) have not followed the modification regarding
mysql_connect() and the new_link parameter (PHP 4.2.0).
Previous Comments:
------------------------------------------------------------------------
[2003-11-05 00:37:40] [EMAIL PROTECTED]
Please read the manual pages for mysql_errno() and mysql_error() about
what parameters they accept and you'll
find out what I meant..
------------------------------------------------------------------------
[2003-11-04 11:20:44] scouture at novo dot ca
Have you been able to reproduce the behavior with the new_link
parameter set to TRUE like I did ?
------------------------------------------------------------------------
[2003-11-04 10:27:52] scouture at novo dot ca
I've got the same result EVEN with the new_link parameter set to TRUE.
echo "first connection<br><br>";
$conn1 = mysql_connect($validIp&Port,$validUser,$validPassword,
true);
if($conn1 == false)
{
echo "<hr>mysql_error : ".mysql_error()."<br>";
echo "mysql_errno : ".mysql_errno()."<hr>";
}
else
echo "ok connected 1";
echo "<hr>second connection<br><br>";
$conn2 = mysql_connect ($validIp&Port,$validUser,$NOTvalidPassword,
true);
if($conn2 == false)
{
echo "<hr>mysql_error : ".mysql_error()."<br>";
echo "mysql_errno : ".mysql_errno()."<hr>";
}
else
echo "ok connected 2";
------------------------------------------------------------------------
[2003-11-04 09:58:34] [EMAIL PROTECTED]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
Always use the link parameter when doing multiple connects in same
scripts. This is no bug.
------------------------------------------------------------------------
[2003-11-04 09:45:51] scouture at novo dot ca
NOTE that mysql_error() & mysql_errno() are returning result has
expected if the first connection failed. So, if the first connection
and the second failed, both mysql_error() & mysql_errno() are ok for
the first and the second connection.
But, if there is already a valid connection to the dbserver, they are
not behaving right for the second in case of failling.
Hope that is clear enought...
Regards
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/26114
--
Edit this bug report at http://bugs.php.net/?id=26114&edit=1