Jump to content

Recommended Posts

Hi guy's!!

 

I try several option but always get the same result.. doesn't work and receive this message

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\...........\SEARCH.php on line 15

 

this is my form

 

<?php
include_once("db_connection.php");
?>
  
<html>  
   <head>  
     <meta  http-equiv="Content-Type" content="text/html;  charset=iso-8859-1">   
    <title>Search  engine</title>  
   </head>  
   <p><body>   
     <h3>Model kit database</h3>  
     <p>You  may search either by reel car or kit manufacturer</p>  
     <form  method="post" action="search.php?go"  id="searchform">   
       <input  type="text" name="name">
       <input  type="submit" name="submit" value="Search">
     </form>  
   </body>  
</html>  
</h2>
<p> </p>
<p> </p>
<br>
<br>

</body>
</html>

 

and this is my search code

 

<?php

include_once("db_connection.php");
   if(isset($_POST['submit'])){   
   if(isset($_GET['go'])){   
   if(preg_match("/^[  a-zA-Z]+/", $_POST['name'])){   
   $name=$_POST['name'];   
      
     //-query  the database table   
   $sql="SELECT  kit_id, description, manufacturer_kit FROM Contacts WHERE description LIKE '%" . $name .  "%' OR manufacturer_kit LIKE '%" . $name ."%'";   
   //-run  the query against the mysql query function   
   $result=mysql_query($sql);   
   //-create  while loop and loop through result set   
   while($row=mysql_fetch_array($result)){   
           $description  =$row['description'];   
           $manufacturer_kit=$row['manufacturer_kit'];   
           $kit_id=$row['kit_id'];   
   
   //-display the result of the array   
   echo "<ul>\n";   
   echo "<li>" . "<a  href=\"search.php?id=$kit_id\">"   .$description . " " . $manufacturer_kit .  "</a></li>\n";   
   echo "</ul>";   
   }   
   }   
   else{   
   echo  "<p>Please enter a search query</p>";   
   }   
   }   
   }   
?>   

 

what is wrong???

 

thanks for your help

 

sebastien

 

Link to comment
https://forums.phpfreaks.com/topic/206559-why-its-not-working/
Share on other sites

The error means that your query failed due to an error (could be a connection problem, a database problem, a table problem, a column problem, or a syntax problem.)

 

If you search for any part of that error message, you find that using mysql_error(); will tell you why the query failed. For troubleshooting purposes (remove it after you are done) echo mysql_error(); on the next line after the line with your mysql_query(...); statement.

Link to comment
https://forums.phpfreaks.com/topic/206559-why-its-not-working/#findComment-1080450
Share on other sites

thanks but now I have an other problem.

 

when I submit the search form I got a BLANK page.... ??????

 

what's going on here ???

 

the  form page does'nt change just the search.php page. ( VERY MINOR ) and I got the same result if I put back the old one. ????

 

<?php

include_once("db_connection.php");
   if(isset($_POST['submit'])){   
   if(isset($_GET['go'])){   
   if(preg_match("/^[  a-zA-Z]+/", $_POST['name'])){   
   $name=$_POST['name'];   
      
     //-query  the database table   
   $sql="SELECT  kit_id, description, manufacturer_kit FROM Contacts WHERE description LIKE '%" . $name .  "%' OR manufacturer_kit LIKE '%" . $name ."%'";  
   

   //-run  the query against the mysql query function   
   $result=mysql_query($sql);   
   //-create  while loop and loop through result set   
   while($row=mysql_fetch_array($result)){   
           $description  =$row['description'];   
           $manufacturer_kit=$row['manufacturer_kit'];   
           $kit_id=$row['kit_id'];   
   
   //-display the result of the array   
   echo "<ul>\n";   
   echo "<li>" . "<a  href=\"search.php?id=$kit_id\">"   .$description . " " . $manufacturer_kit .  "</a></li>\n";   
   echo "</ul>";   
   }   
   }   
   else{   
   echo  "<p>Please enter a search query</p>";   
   }   
   }   
   }
?>   

 

did my coding is good ???

Link to comment
https://forums.phpfreaks.com/topic/206559-why-its-not-working/#findComment-1080482
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.