解析错误:语法错误,意外'如果'第5行的C:\ xampp \ htdocs \ Search \ search.php中的(T_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 = $_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>';
}
}
}
?>
答案 0 :(得分:2)
请在下一行添加分号(;)
mysql_select_db("search") or die("could not find db");