我正在尝试构建一个搜索系统。我使用的是mySQL系统,但是我没什么经验,我也不太明白。
我的尝试因致命错误而失败
<?php
$proto = $_GET['proto'];
$terms = $_GET['f'];
if($proto == 'inline'){
$searchpattern = mysql_real_escape_string(strtoupper($terms));
$list = mysql_query("SELECT id,
post_title, post_date
FROM wp_posts
WHERE post_title LIKE '%$searchpattern%'
)
ORDER BY post_date;");
while ($row = mysql_fetch_array($list)) {
$title = $row['post_title'];
$date = $row['post_date'];
$url = $row['guid'];
$date = date($date, 'd M Y');
$return .= '<li>
<a href="#sidebar3" onClick="slide(this); return false" title="" rel="'.$id.'" style="line-height:16px;">'.$firstname.' '.$lastname.'<br /><span style="font-size:10px; color:#555;">'.$email.'</span></a>
</li>
<div class="title"><b>SEARCH RESULTS</b></div>
<a href="'.$url.'"><img src=""/>'. $title .' - <span>'. $date .'</span></a>';
}
}
?>
答案 0 :(得分:1)
$list = mysql_query("SELECT id, post_title, post_date
FROM wp_posts
WHERE post_title LIKE '%$searchpattern%') ORDER BY post_date;");
“ORDER”运算符之前有意外的“)”。
答案 1 :(得分:0)
ORDER BY之前有一个空心括号。也许这就是导致问题的原因