在我当前的 PHP 脚本中出现此错误:未定义的偏移量:1
我的代码在这里:
$query = "SELECT item_id, username, item_content FROM updates ORDER BY update_time DESC LIMIT " . $start . ", " . $number_of_posts;
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
preg_match("/<p>(.*)<\/p>/",$row['item_content'],$matches);
$row['item_content'] = strip_tags($matches[1]);
$posts[] = $row;
}
如果您看到导致此问题的原因,请在下面发布确实会有所帮助。谢谢! :)
代替
$row['item_content'] = strip_tags($matches[1]);
Try
if (isset($matches[0]) && isset($matches[0][1]))
$row['item_content'] = strip_tags($matches[0][1]);
else
$row['item_content'] = '';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)