简体   繁体   中英

Fatal error: Call to a member function query() on a non-object expressionengine

I have no idea why this error is happening, it's shown in all the expressionengine tutorials and on the forums yet for some reason I still get it? line 43 is shown in the script

class upload_pictures
{
    public function upload_pictures()
    {
        if (!isset($whats_gonna_happen))
        {
            $uploads='';
            $cout=1;
            if (!table_exists('albums'))
            {
                                    //line 43 below
                $this->EE->db->query("CREATE TABLE albums(
                    id INT NOT NULL AUTO_INCREMENT,
                    PRIMARY KEY(id)
                    name VARCHAR(50)
                ") or die(mysql_error());
            }
            $stuff=$this->EE->db->query('SELECT id, name FROM albums');

I found the problem, it was in expressionengine you need to have the line

$this->EE=& get_instance();

in the constructor to get to the superglobals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM