Call to a member function escape_string() on a non-object
#1

I'm learning mysqli and when creating a URL Shortener I get this error: Call to a member function real_escape_string() on a non-object on this line:
PHP код:
$url $this->db->escape_string($url); 
PHP код:
class Shortener {
    protected 
$db;
    public function 
_construct()  {
        
$this->$db = new mysqli('localhost''root''*****''shortn');
    } 
I have not forgot to close the class before any one tries to point that out.
Reply
#2

Anyone?
Reply
#3

@Edit,

You have:
PHP код:
$this->$db = new mysqli... 
Wasn't it supposed to be
PHP код:
$this->db = new mysqli... 
?

Check the post below as well!
Reply
#4

PHP код:
public function __construct()  //__construct 2x __{ 
Reply
#5

Thanks both of you. They both helped fixed errors!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)