Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/xyz.com/httpdocs/casa/catalogclass.php on line 109
here is the code Im using. (I am new to this please be easy)
PHP Code:
<?
require_once "databaseclass.php";
class catalogclass extends databaseclass{
var $thumbnail;
var $mainpic;
var $description;
var $directory;
var $directory1;
var $pagesize;
var $pageindex=0;
var $rows;
var $rowcount;
var $i=0;
var $row;
var $condition;
var $category;
var $command;
function setThumbnail($value){
$this->thumbnail=$value;
}
function setMainPic($value){
$this->mainpic=$value;
}
function setDescription($value){
$this->description=$value;
}
function setDirectory($value){
$this->directory=$value;
}
function setDirectory1($value){
$this->directory1=$value;
}
function setPageSize($value){
$this->pagesize=$value;
}
function setPageIndex($value){
$this->pageindex=$value-1;
}
function getSearch(){
return $this->queryME("select * from Catalog WHERE title LIKE '%$search%' || description LIKE '%search%' || category LIKE '%$search%'");
}
function getCategories(){
return $this->queryME("SELECT category from Catalog group by category");
if($this->category!="All" && $this->category!=""){
$this->rows=$this->queryME("SELECT count(*) as size from Catalog where category='".$this->category."'");
}else{
$this->rows=$this->queryME("SELECT count(*) as size from Catalog");
}
A class object didn't get created somewhere. Its not the class that you are using its an argument to a class method that is of datatype "object" that this class needs.
The error is your class complaining that it didn't get something that it needed. look at the code that "calls" the object instance of the class and look for a parameter or argument that is a class object. In most cases its probably one or two lines above where this method is called.
You get experienced by solving lots of these sorts of problems.
Keep plugging away!
__________________
"Things are difficult only while you don't understand them."
$databaseobject->queryMe("DELETE FROM Catalog where itemid ='$itemid'")
A non-object means that $databaseobject is not an instance of the database class you're using. So either you need to make an instance of that class in $databaseobject:
PHP Code:
$databaseobject = new DatabaseObject();
(or something similar)
Or there's an error in your database class.
__________________ Jack Bauer makes Chuck Norris cry
Ok so I think I have the command to work, but now I get this error.
catalogclass.php
PHP Code:
<?
require_once "databaseclass.php";
class catalogclass extends databaseclass{
var $thumbnail;
var $mainpic;
var $description;
var $directory;
var $directory1;
var $pagesize;
var $pageindex=0;
var $rows;
var $rowcount;
var $i=0;
var $row;
var $condition;
var $category;
var $command;
var $delete;
function setThumbnail($value){
$this->thumbnail=$value;
}
function setMainPic($value){
$this->mainpic=$value;
}
function setDescription($value){
$this->description=$value;
}
function setDirectory($value){
$this->directory=$value;
}
function setDirectory1($value){
$this->directory1=$value;
}
function setPageSize($value){
$this->pagesize=$value;
}
function setPageIndex($value){
$this->pageindex=$value-1;
}
function getDelete(){
return $this->queryME("DELETE FROM Catalog where itemid ='$itemid'");
}
function getCategories(){
return $this->queryME("SELECT category from Catalog group by category");
if($this->category!="All" && $this->category!=""){
$this->rows=$this->queryME("SELECT count(*) as size from Catalog where category='".$this->category."'");
}else{
$this->rows=$this->queryME("SELECT count(*) as size from Catalog");
}