Welcome Guest, Not a member yet? Register   Sign In
Call to a member function real_escape_string() on a non-object
#15

I have fixed it in the following way:

The problem is given because when the update of the cookie in the database is made, the connection with the database has been closed.
My solution is this:

File system / database / DB_driver.php:

Original method:

public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}

return $str;
}

$str = $this->_escape_str($str);

// escape LIKE condition wildcards
if ($like === TRUE)
{
return str_replace(
array($this->_like_escape_chr, '%', '_'),
array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
$str
);
}

return $str;
}

Modifications of the method:

public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}

return $str;
}


if($this->conn_id === FALSE){
$this->initialize();
}

$str = $this->_escape_str($str);

// escape LIKE condition wildcards
if ($like === TRUE)
{
return str_replace(
array($this->_like_escape_chr, '%', '_'),
array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
$str
);
}

return $str;
}

the only thing that checks if the connection has been closed, I reopen it.
Reply


Messages In This Thread
RE: Call to a member function real_escape_string() on a non-object - by edures - 06-10-2019, 04:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB