Possible Duplicate:
supplied argument is not a valid MySQL result resource
I am trying to show results from my database on my site but I keep getting an error message or nothing shows.
The error message at the moment in time is:
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
This is an updated version from my previous question as I have edited the php but it still doesnt work. What am I doing wrong?
James
<?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();
?>