title: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7214280/supplied-argument-is-not-a-valid-mysql-result-resource">supplied argument is not a valid MySQL result resource </a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to show results from my database on my site but I keep getting an error message or nothing shows.</p>
  
  <p>The error message at the moment in time is:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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?</p>
  
  <p>James</p>
  
  <pre><code>&lt;?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 "&lt;h2&gt;Search Results&lt;/h2&gt;&lt;ol&gt;";
  while ($data_fetch = mysql_fetch_array($query_for_result))
  {
  echo '&lt;br&gt;';
  echo '&lt;br&gt;';
  echo '&lt;div class="data1"&gt;';
  echo $data_fetch["name"];
  echo '&lt;/div&gt;';
  echo '&lt;br&gt;';
  echo '&lt;div class="data2"&gt;';
  echo $data_fetch["email"];
  echo '&lt;/div&gt;';
  echo '&lt;br&gt;';
  echo '&lt;div class="data3"&gt;';
  echo $data_fetch["location"];
  echo '&lt;/div&gt;';
  }
  echo "&lt;/ol&gt;";
  
  mysql_close();
  ?&gt;
  </code></pre>