Jump to content

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?

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.