Solved

MySQL search sometimes returns all results

Posted on 2007-11-19
6
176 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
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

821 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