Solved

MySQL search sometimes returns all results

Posted on 2007-11-19
6
175 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 142

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to dynamically set the form action using jQuery.
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…

777 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