我正在嘗試在我的網站上實施實時搜索。Jquery實時搜索
我正在使用某人已創建的腳本。 http://www.reynoldsftw.com/2009/03/live-mysql-database-search-with-jquery/
我得到了jquery,css,html正常工作,但我有麻煩的PHP。
我需要改變它包含我的數據庫信息,但每次我做我收到一個錯誤:
警告:mysql_fetch_array()預計參數1是資源,布爾在C中給出:\ WAMP \ WWW \搜索.PHP線路33
這是我的數據庫的詳細信息:
數據庫名稱:發展
表名:鏈接
列:ID,網站名稱,主頁,描述,分類
這是在PHP腳本
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "password";
$dbname = "links";
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
if(isset($_GET['query'])) { $query = $_GET['query']; } else { $query = ""; }
if(isset($_GET['type'])) { $type = $_GET['type']; } else { $query = "count"; }
if($type == "count")
{
$sql = mysql_query("SELECT count(url_id)
FROM urls
WHERE MATCH(url_url, url_title, url_desc)
AGAINST('$query' IN BOOLEAN MODE)");
$total = mysql_fetch_array($sql);
$num = $total[0];
echo $num;
}
if($type == "results")
{
$sql = mysql_query("SELECT url_url, url_title, url_desc
FROM urls
WHERE MATCH(url_url, url_title, url_desc)
AGAINST('$query' IN BOOLEAN MODE)");
while($array = mysql_fetch_array($sql)) {
$url_url = $array['url_url'];
$url_title = $array['url_title'];
$url_desc = $array['url_desc'];
echo "<div class=\"url-holder\"><a href=\"" . $url_url . "\" class=\"url-title\" target=\"_blank\">" . $url_title . "</a>
<div class=\"url-desc\">" . $url_desc . "</div></div>";
}
}
mysql_close($conn);
?>
任何人可以幫助我輸入這個數據庫的信息是否正確?我已經嘗試了很多次,但不斷收到錯誤。提前致謝。
編輯:它是連接到沒有錯誤的數據庫。請在這裏檢查http://movieo.no-ip.org/
您有一個SQL注入漏洞。 – SLaks 2010-03-23 22:07:56
[mysql \ _fetch \ _array()的可能的重複期望參數1是資源,布爾給出在選擇](http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to -be-resource-boolean-given-in-select) – 2013-07-15 17:41:28