开发者

Failed to insert a row [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

What is wrong with following code? Without smiley function it works and with $tz = smiley($this->text); doesn't.

I tried to put to display the errors but .. mhmm doesn't works.. 0 errors

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

   开发者_如何学JAVA     // 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;
    }
}
?>


You've enabled error reporting by placing the appropriate function calls... outside a PHP code block! Instead of this:

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

<?php
// ...
?>

... do this:

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

// ... 
?>

Then PHP will tell you that there isn't a function called smiley(). There is, however, a class method: $this->smiley().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜