Failed to insert a row [closed]
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()
.
精彩评论