Hello, let me ask you something. I have a problem with mysql_error()
function after using mysql_connect(). Please look at thiese two examples:
Example 1
$link = mysql_connect($host, $user, $pswd) or die(Could not connect to
$host because: . mysql_error());
/Example 1
Example 2
$link1 = mysql_connect($host1, $user, $pswd) or die(Could not connect to
$host because: . mysql_error());
mysql_select_db($db, $link1);
// ... and here the code is going
// to query the selected DB
// Then I need to connect to another DB
$link2 = mysql_connect($host2, $user, $pswd) or die(Could not connect to
$host because: . mysql_error());
// ... and here the code is going to work
// with another connection to another database
/Example 2
QUESTION and PROBLEM:
The first example work excelent, so when for example bad password is given,
the output is: Could not connect do _HOST_ because: Access denied for user
'_USER_'@'%'
(or something like it)
Lets have a look on the second example:
Lets say, that first connection works perfectly, so all quiries are well
done. But lets say, that second connection has wrong user/password given.
Then the error output is:
Could not connect to _HOST2_ because:
The error message for second connection request is not given back to the
PHP. Or as I suppose, mysql_error takes last error message from last used
ESTABLISHED connection (it means from $link1) and since in this connection
was everything ok, it puts empty string as a result of mysql_error function.
What can I do to get really last error message from mysql server? Last error
message is dedicated to last mysql_connection function, but since $link2 is
not established it is not given as a result of mysql_error function.
Can anybody help me, how to get really last error message that is
dedicated to last connection request?
Thanks a lot for any advice.
Honza Spurny
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php