Possible Duplicate:
supplied argument is not a valid MySQL result resourcemysql_fetch_array():提供的參數不是一個有效的MySQL結果資源
我試圖展現在我的網站從我的數據庫的結果,但我不斷收到一個錯誤信息或者什麼也不顯示。
在時間中的時刻的錯誤信息是:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /websites/123reg/LinuxPackage22/we/ez/y_/weezy.co.uk/public_html/search.php on line 29
這是我剛纔的問題的更新版本,因爲我已經編輯了PHP,但它仍然不工作。我究竟做錯了什麼?
詹姆斯
<?php
// Change the fields below as per the requirements
$db_host="";
$db_username="u2";
$db_password="";
$db_name="";
$db_tb_name="";
$db_tb_atr_name[0]="name";
$db_tb_atr_name[1]="email";
$db_tb_atr_name[2]="location";
//Now we are going to write a script that will do search task
// leave the below fields as it is except while loop, which will display results on screen
mysql_connect("$db_host","$db_username","$db_password");
mysql_select_db("$db_name");
$query_for_result=mysql_real_escape_string($_GET['query']);
$query_for_result=mysql_query("
SELECT $db_tb_atr_name[0], $db_tb_atr_name[1], $db_tb_atr_name[2]
FROM $db_tb_name WHERE
$db_tb_atr_name[0], $db_tb_atr_name[1], $db_tb_atr_name[2] LIKE '%".$query."%'");
echo "<h2>Search Results</h2><ol>";
while ($data_fetch = mysql_fetch_array($query_for_result))
{
echo '<br>';
echo '<br>';
echo '<div class="data1">';
echo $data_fetch["name"];
echo '</div>';
echo '<br>';
echo '<div class="data2">';
echo $data_fetch["email"];
echo '</div>';
echo '<br>';
echo '<div class="data3">';
echo $data_fetch["location"];
echo '</div>';
}
echo "</ol>";
mysql_close();
?>
當你這樣做的數據庫查詢隨時添加'或死亡(mysql_error())'在年底,所以你會看到,如果有查詢錯誤。 – JJJ
你已經給了一個答案 - http://stackoverflow.com/questions/8327003/keep-getting-the-same-mysql-error-how-do-i-overcome-this – matino
啊,好舊的'「$ var 「'貨物 - 邪教編程... –