lora
lora

Reputation: 3

Catchable fatal error of a Class - PHP

Getting this error... (MySQLiPluggin is my database class name)

Catchable fatal error: Object of class MySQLiPluggin could not be converted to string

I have a php form, that posts the data, and trying to add to the database.

if(isset($_POST["submit"])){    

    $formNewTreatment->setStickyData($_POST);
    $formNewTreatment->checkNotEmpty("treatName");
    $formNewTreatment->checkNotEmpty("treatPrice");
    $formNewTreatment->checkNotEmpty("treatBlurb");

    if ($form->valid){

        $addTreatment = new Treatment();

        $addTreatment->setTreatName($_POST["treatName"]);
        $addTreatment->setTreatPrice($_POST["treatPrice"]);
        $addTreatment->setTreatBlurb($_POST["treatBlurb"]);
        $addTreatment->setSubID($_POST["treatCategory"]);
        $addTreatment->addTreatments();

            $sAdminMessage = "saved SMILEYFACE";    

        }else{

            $sAdminMessage = "not saved SADFACE";

        }

}

When I click submit, I get the the above error.

Here is my $addTreatment:

    public function addTreatments(){
        global $database;

        if($this->bExisting == false){

            $sQuery = "INSERT INTO treatments (`treatmentName`, `treatmentPrice`, `treatmentBlurb`, `subID`) 
            VALUES ('".$database->escape_value($this->sName)."', '".$database->escape_value($this->sPrice)."', '".$database->escape_value($this->sBlurb)."', '".$database->escape_value($this->iSubID)."')";

            $resultAddTreatment = $database->query($sQuery);

            if($resultAddTreatment){

                $this->$iTreatmentID = $this->$database->get_last_insert_id();

                $this->bExsisting = true;

            }else{

                    die("save has failed, you've done something wrong.");

            }

        }

    }

Thanks. :)

Upvotes: 0

Views: 168

Answers (1)

Eric Petroelje
Eric Petroelje

Reputation: 60518

Well, not sure if it's the bug that is causing the problem, but this looks like a bug to me:

$this->$database->get_last_insert_id();

Should probably be:

$database->get_last_insert_id();

Upvotes: 1

Related Questions