Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#62 Errorhandling on connect

Next_Version
closed-accepted
5
2006-10-18
2006-10-17
Allard
No

The function ErrorNo() reports no error while using
the code used below. (see EXAMPLE)
For example i used an wrong password to the connection
but it reports no error.

To solve the problem i changed the msql_driver.inc for
the functions ErrorNo() & ErrorMsg() to solve the
problem.
(see below CHANGED CODE)

-------------------- EXAMPLE --------------------------
---
$db = ADONewConnection('mysql','pear');
$db->Connect
(SITE_DB_HOSTNAME,SITE_DB_USERNAME,SITE_DB_WRONGPASSWOR
D,SITE_DB_NAME);

if ($db->ErrorNo()>0) {
echo $db->ErrorMsg() . "<br>";
echo "Database error, please contact support.";
die();
}

echo "Connection is made!";

------------------- END -------------------------------
----

------------------ CHANGED CODE -----------------------
----

/**
* Return database error message
* Usage: $errormessage =& $db->ErrorMsg();
*
* @access public
*/

function ErrorMsg()
{
if ($this->connectionId) {
return @mysql_error($this->connectionId);
} else {
return @mysql_error();
}
}

/**
* Return database error number
* Usage: $errorbo =& $db->ErrorNo();
*
* @access public
*/

function ErrorNo()
{
if ($this->connectionId) {
return @mysql_errno($this->connectionId);
} else {
return @mysql_errno();
}
}

-------------------------------------------------------
------------------------

Discussion

  • Mark Dickenson
    Mark Dickenson
    2006-10-18

    Logged In: YES
    user_id=752816

    Thanks, all drivers will be updated for the next release.

     
  • Mark Dickenson
    Mark Dickenson
    2006-10-18

    • milestone: --> Next_Version
    • status: open --> closed-accepted