Solved

MySQL search sometimes returns all results

Posted on 2007-11-19
6
173 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
6 Comments
 
LVL 2

Expert Comment

by:eulac
Comment Utility
can you paste your search code with the sql statement here...
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
Giving the query and related code, as eulac suggested, would be very helpful.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

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

Expert Comment

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

Accepted Solution

by:
geist62 earned 0 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now