你好用PHP林不知道另外一個問題,爲什麼它不工作,但這裏是代碼:不工作的另一個動態表(搜索引擎)
<?php include 'db.inc.php';function search_results($keywords){$returned_results = array();
$where = "";
$keywords = preg_split('/[\s]+/', $keywords);
$total_keywords = count($keywords);
foreach($keywords as $key=>$keyword){
$where .="`keywords` LIKE '%$keyword%'";
if ($key != ($total_keywords - 1)){
$where .= " AND ";
}
}
$results = "SELECT `document_name` ,LEFT(`first_paragraph`,70) as `first_paragraph` FROM `documents` WHERE $where ";
$results_num = ($results = mysql_query($results)) ? mysql_num_rows($results) : 0 ;
if ($results_num == 0){
return false;
}else {
while($results_row = mysql_fetch_assoc($results)){
$returned_results[] = array(
'title' => $results_row['document_name'],
'description' => $results_row['first_paragraph']
);
}
return $returned_results;
}
}
?>
我試着在此刻與PDO作,但即時通訊不知道如何.. 即時通訊不知道如果這是問題,但我沒有從MySQL Thx爲你的時間!
您是否正在連接到您的db.inc.php文件?我總是有這樣的:include_once('db.inc.php'); – Jim
是的,我連接到db –
你得到了什麼錯誤 - 具體是你得到MySQL錯誤? –