Parse error: syntax error, unexpected ';', expecting ',' or ')' in /home/u459249666/public_html/ss/search.php on line 19PHPのエラー:パースエラー
$confiq = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'hunklessons',
);
$db = new PDO('mysql:host='.$confiq['host'].';dbname='.$confiq['dbname'],$confiq['username'],$confiq['password'].'');
if(isset($_GET['s']) && !empty($_GET['s'])) {
//secure the search input
$search = trim(strip_tags($_GET['s']));
//convert the space in the search to sepreate terms
$search_terms = explode(" ", $search);
$term_count = 0;
$q = "";
$result = array();
$i = 0;
foreach ($search_terms as $term) {
$term_count++;
if($term_count === 1) {
$q .= "`title` LIKE '%$term%' ";
} else {
$q .= "AND `title` LIKE '%$term%' ";
}
}
//prepare the mysql query in PDO
$query = $db->query("SELECT * FROM `google_search` WHERE $q");
//get the number of the results found
$num = $query->rowCount();
if ($num > 0) {
//fetch the result
while($row = $query->fetch(PDO::FETCH_ASSOC)){
//put the results in the array
$result[$i] = array(
'title' => $row['title'],
'desc' => $row['description'],
'link' => $row['link']
);
$i++;
}
}
//convert result array into json format
$json_result = json_encode($result);
echo $json_result;
}
このスクリプトを実行するには、私は
を取得していますが、私はエラーがそれを補正することができる方法が何であるかを理解することはできませんよ。parse error in line 19
私はたくさん試しました。私は初心者なので時々非常に混乱します。