SA-MP Forums Archive
Call to a member function escape_string() on a non-object - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: Call to a member function escape_string() on a non-object (/showthread.php?tid=515588)



Call to a member function escape_string() on a non-object - BleverCastard - 26.05.2014

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.


Re: Call to a member function escape_string() on a non-object - BleverCastard - 27.05.2014

Anyone?


Re: Call to a member function escape_string() on a non-object - GWMPT - 27.05.2014

@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!


Re: Call to a member function escape_string() on a non-object - Isolated - 27.05.2014

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



Re: Call to a member function escape_string() on a non-object - BleverCastard - 28.05.2014

Thanks both of you. They both helped fixed errors!