Jump to content

My member search works in Firefox but not in IE. What gives?


craigjonson

Recommended Posts

I have a search box on my website that searches the mysql database for members. I thought it was working great until I tried it in Internet Explorer.

 

This is the problem, in IE when the search is successful (member is found in database) it displays nothing. What is weird though, is that if the search fails, (member does not exist) it displays the error message as expected. If anyone could take a look at my code below, and let me know if you have any suggestions it would be greatly appreciated.

 

 

$query = "SELECT * FROM members WHERE username LIKE '%$word%'";

            $numresults=mysql_query($query);
            $num_rows=mysql_num_rows($numresults);

            if ($num_rows != 0)
              {
                  $result = mysql_query($query) or die("Couldn't execute query");
                   /* Display table with results */
                   echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><br>";
                   for($i=0; $i < $num_rows; $i++){
                      $uname = mysql_result($result,$i,"username");
                      $id = mysql_result($result,$i,"member_id");

                      echo "<td><a href=\"profile.php?id=$id\">$uname</a>   </td><td><br>";
                   }
                   echo "</table><br/><br>";
              } else
                    echo "No members found.";

Don't use:

 

$result = mysql_query($query) or die("Couldn't execute query");

 

What usefull information does "Couldn't execute query" contain for your visitors?

 

Please post your entire code, what does $word contain?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.