Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySQL search sometimes returns all results

Posted on 2007-11-19
6
Medium Priority
?
179 Views
Last Modified: 2013-12-13
I have a search and results page.  For the first time today, I noticed that when I search in the surname for a specific surname it returns every entery in my database.  However a few minutes latter I return to conduct a new search and it works fine returning only the results I specify.

Any ideas why this would occur? Thanks!
0
Comment
Question by:geist62
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:eulac
ID: 20313196
can you paste your search code with the sql statement here...
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20313202
would surprise me alot.
I rather have to guess that your search/results pages do not save the value correct to be searched for, and search LIKE '%' eventually?!
0
 
LVL 7

Expert Comment

by:dansoto
ID: 20313215
Giving the query and related code, as eulac suggested, would be very helpful.
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:geist62
ID: 20313238
I will post the code latter this afternoon. Thanks very much!
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 20315073
Also, which surname causes the issue?  Does it have a space in it?
0
 

Accepted Solution

by:
geist62 earned 0 total points
ID: 20316815
My script is set up so that if a space is entered before the surname or after the user has to re-enter the surname. So I don't imagine that is the problem.  My searches appear to be working again.  The code on my search page is as follows:

------------->Start of code
<form action="" method="post" name="WADASearchForm" form class="noimage" border="1" id="WADASearchForm">
                        <p class="style3">
                          <span class="style1">
                          <?php $errors = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
   
     $S_Surname = mysql_real_escape_string( $_POST['S_Surname'] );
     $S_SurnameLength = strlen( $S_Surname );

     if (ereg('[^A-Za-z]', $S_Surname) OR strlen($S_Surname)<3 OR strlen($S_Surname)>25) {
          $errors = "<p>*Please enter a surname.</p>";
          }
   

     if ( $errors != "" )  
          echo $errors;
     else {
          if ($_SERVER["REQUEST_METHOD"] == "POST") {

               $qryStr = "";
               foreach( $_POST as $ky => $val )
                    $qryStr .= "$ky=".urlencode($val)."&";

               if ( strlen($qryStr) > 0 )
               $qryStr = "?" . substr( $qryStr, 0, -1 );
               $url ="Postcards_Results.php$qryStr";
               Header("Location: $url");
               exit;
          }

     }
}
?>
                          </span></p>
                         
<div align="left">
                          <table width="210" border="0">
                           <tr>
                              <td>Find your ancestor's holiday spot!</td>
                           <tr>
                      <td><div align="left"></div>                        
                        <input type="text" name="S_Surname" id="S_Surname"  size="25" VALUE="Enter a surname" onfocus="makeBlank()"/></td>
                           
                            <tr>
                              <td width="194"><div align="right"><span class="WADADataNavButtonCell">
                                <input type="image" hspace="0" vspace="0" border="0" name="Search" id="Search" value="Search" alt="Search" src="siteassist_images/Refined_search.gif"  />
                                </span></div></td>
                            </tr>
                            <tr>
                              <td><div align="right"><a href="Search.php" title="Advanced Search" style="color:white">Advanced Search</a></div></td>
                            </tr>
                          </table>
              </div>
                        <div class="WADAButtonRow">
                          <table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                              <td class="WADADataNavButtonCell" nowrap="nowrap">&nbsp;</td>
                            </tr>
                          </table>
                        </div>
            </form>

----------------->End of Code
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question