2011-02-02 8 views
0

이 오류를 얻기는 ... 내가 게시물 데이터 및 데이터베이스에 추가하려는 것으로, PHP는 양식이잡아낼 치명적인 오류 - PHP

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

(MySQLiPluggin 내 데이터베이스 클래스 이름입니다) .

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"; 

     } 

} 

제출을 클릭하면 위의 오류가 발생합니다.

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."); 

      } 

     } 

    } 

감사 :

은 여기 내 $의 addTreatment입니다. :)

+2

그렇게하지 제공된 코드에서 발생할 수있는 부분을 확인하십시오. 오류에 주어진 줄 번호는 무엇이며 어떤 줄이 있습니까 (제공되지 않으면 편집 할 수 있습니까)? – ircmaxell

+0

그리고'MySQLiPluggin' 클래스는 무엇입니까? – lonesomeday

+0

MySQLiPluggin이 제 데이터베이스 클래스입니다. 죄송합니다 – lora

답변

1

음, 문제의 원인이되는 버그, 그러나 이것은 나에게 벌레처럼 보이는 있는지 확실하지 않습니다 :

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

아마해야합니다

$database->get_last_insert_id();