我得到一个错误,说trim()期望参数1是字符串,给定数组。这是第二行:
$page_result = $title_result->FetchRow();
if (strlen(trim($page_result)) > 0)
$this->body = stripslashes(urldecode($page_result['title_module_text']));
else
$this->body = "";
我认为trim()的第一个参数是一个字符串?
答案 0 :(得分:3)
来自MySQL文档:array mysql_fetch_row ( resource $result )
“返回一个与获取的行对应的数字数组,并将内部数据指针向前移动。”
查看http://php.net/manual/de/function.mysql-fetch-row.php
<?php
$result = mysql_query("SELECT id, name FROM people WHERE id = '32'");
if (!$result) {
echo 'Error: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo $row[0]; // 32
echo $row[1]; // the name value
?>
答案 1 :(得分:2)
<?php
$page_result = $title_result->FetchRow();
$title_module_text = trim($page_result['title_module_text']);
if (strlen($title_module_text) > 0)
$this->body = stripslashes(urldecode($title_module_text));
else
$this->body = "";