-2

I cannot get my insert function working. I have used this frame work.

https://github.com/ajillion/PHP-MySQLi-Database-Class

The error i get is

Fatal error: Call to a member function insert() on a non-object in /home/hghdigib/public_html/backup/feed/classes/xml_upload.php on line 39

I have stripped lost out to make it easier to follow.

Any help would be much appreciated been scratching my head for a while.

My Global Class File

require_once("classes/database.php");
require_once("classes/xml_upload.php");
$db = new Mysqlidb('localhost', '', '', '');
$dataupload = new DataUpload($db);
$dataupload->getAllProducts($db);

My xml_upload.php class

class DataUpload {

    public $db;
    public $xml_upload;

    function __construct($db) {
        $this->db = $db;
    }   

    public function getAllProducts() {
        foreach ($propertys as $results)
        {
            $insertData = array(
                'prop_id' => $results['prop_id'],
                'lastchanged' => $results['lastchanged'],
                'url' => $results['url']
            );

            if($db->insert('propertie_ids', $insertData)) echo 'success!';
        }

    }       

}
Brent
  • 2,385
  • 10
  • 39
  • 63

1 Answers1

2
if($db->insert('propertie_ids', $insertData)) echo 'success!';

Use $this->db instread of $db. You must refer to $this if you want to access class members.

$this->db->insert('propertie_ids', $insertData)
Tim S.
  • 13,597
  • 7
  • 46
  • 72