2011-09-09 20 views
-3

次のコードで何が問題になっていますか?スマイリー機能がなければ、それは働きます。$ tz = smiley($ this-> text);はありません。行を挿入できません

私はあなたが適切な関数を呼び出す配置することによって、エラー報告を有効にしている... PHPコードの外.. mhmmが動作しないエラーが、...を表示するために入れて0エラー

ini_set('display_errors',1); 
error_reporting(E_ALL); 


<?php 
class ChatLine extends ChatBase 
{ 
    protected $text = '', $author = '', $gravatar = ''; 
    public function save() 
    { 
     $tz = smiley($this->text); 

     DB::query(" 
      INSERT INTO webchat_lines (author, gravatar, text) 
      VALUES (
       '".DB::esc($this->author)."', 
       '".DB::esc($this->gravatar)."', 
       '".$tz."' 
     )"); 

     // Returns the MySQLi object of the DB class 
     return DB::getMySQLiObject(); 
    } 

    public function smiley($text) 
    { 
     $privatesmilies = array(
      ":)" => "smile1.gif", 
      ";)" => "wink.gif" 
     ); 

     reset($privatesmilies); 
     while (list($code, $url) = each($privatesmilies)) 
      $text = str_replace($code, "<img src=http://127.0.0.1/chat/img/$url align=absmiddle/>", $text); 

     return $text; 
    } 
} 
?> 
+1

$ tz = $ this-> smiley($ this-> text);を試してください。 – ajacian81

+0

ありがとうございました!!! :) –

+1

このリンゴは何が問題なのですか? _Please_ **なぜそれが機能しないのかについていくつかの説明をしてください。 – Bojangles

答えて

2

を試してみましたブロック!この代わりに:

ini_set('display_errors',1); 
error_reporting(E_ALL); 

<?php 
// ... 
?> 

が...次の操作を行います。

<?php 
ini_set('display_errors',1); 
error_reporting(E_ALL); 

// ... 
?> 

その後、PHPはsmiley()と呼ばれる機能がないことを教えてくれます。しかし、クラスメソッド:$this->smiley()があります。

+0

私は全体のコードを投稿したとき、私は報告の誤りを消しました。 –

関連する問題