#9 The Parameters and return for mysqli_real_connect is wrong

Old_Version
closed-accepted
nobody
None
5
2005-08-24
2005-08-24
Anonymous
No

The Parameters and return for mysqli_real_connect is wrong.
To patch mysqli_driver.inc :

=============================================================================
Source:
=============================================================================

function _connect($host = "", $username = "",
$password = "", $database = "", $persistent, $forcenew)
{
if (!function_exists('mysqli_real_connect')) return
false;

if ($host != "") $this->host = $host;
if ($username != "") $this->username = $username;
if ($password != "") $this->password = $password;
if ($database != "") $this->database = $database;
$this->persistent = $persistent;
$this->forcenewconnection = $forcenew;

if($this->persistent == 1)
{
$this->connectionId = @mysqli_connect( $this->host,
$this->username, $this->password, $this->database );
}
else
{
$this->connectionId = @mysqli_init();
$this->connectionId = @mysqli_real_connect(
$this->host, $this->username, $this->password,
$this->database );
}

if ($this->connectionId === false) return false;
if (!empty($this->database)) return $this->SelectDB(
$this->database );
return true;
}

=============================================================================
Fixed:
=============================================================================
function _connect($host = "", $username = "",
$password = "", $database = "", $persistent, $forcenew)
{
if (!function_exists('mysqli_real_connect')) return
false;

if ($host != "") $this->host = $host;
if ($username != "") $this->username = $username;
if ($password != "") $this->password = $password;
if ($database != "") $this->database = $database;
$this->persistent = $persistent;
$this->forcenewconnection = $forcenew;
if($this->persistent == 1)
{
$this->connectionId = @mysqli_connect( $this->host,
$this->username, $this->password, $this->database );
}
else
{
$this->connectionId = @mysqli_init();
@mysqli_real_connect($this->connectionId,
$this->host, $this->username, $this->password,
$this->database );
}
if (mysqli_connect_errno() != 0)
{
$this->connectionId = false;
}
if ($this->connectionId === false) return false;
if (!empty($this->database)) return $this->SelectDB(
$this->database );
return true;
}

Discussion

  • Mark Dickenson
    Mark Dickenson
    2005-08-24

    Logged In: YES
    user_id=752816

    Thanks for the fix. I have added it to the next version. :)

     
  • Mark Dickenson
    Mark Dickenson
    2005-08-24

    • status: open --> closed-accepted