Solved

MySQL search sometimes returns all results

Posted on 2007-11-19
6
177 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

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

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Creating and Managing Databases with phpMyAdmin in cPanel.
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 dynamically set the form action using jQuery.

710 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