PHP实时搜索错误
分析错误:语法错误,第5行C:\xampp\htdocs\Search\Search.php中出现意外的“if”(T\u if) 无法解释我的if有什么问题PHP实时搜索错误,php,Php,分析错误:语法错误,第5行C:\xampp\htdocs\Search\Search.php中出现意外的“if”(T\u if) 无法解释我的if有什么问题 <?php mysql_connect("localhost","root","") or die("could not connect"); mysql_select_db("search") or die("could not find db") if(isset($_POST['search'])){ $searchq
<?php
mysql_connect("localhost","root","") or die("could not connect");
mysql_select_db("search") or die("could not find db")
if(isset($_POST['search'])){
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = mysql_query("SELECT * FROM students WHERE firstname LIKE '%$searchq%' OR lastname LIKE '%$searchq%'") or die("could not search!");
$count = mysql_num_rows($query);
}
if($count == 0){
$result = 'There was no search results!';
else{
while($row = mysql_fetch_array($query)){
$fname = $row['firstname'];
$lname = $row['lastname'];
$id = $roq['ic'];
$output .= '<div>'.$fname.' '.$lname.'</div>';
}
}
}
?>
请在下一行添加分号(;)
mysql_select_db("search") or die("could not find db");