Page 1 of 1

This boolean search somehow doesn't work...

Posted: Sat May 29, 2004 12:33 am
by augustus_emperor

Code: Select all

<?php  
   /* call this script "advs.php" */ 
   if(!$c) {  
?> 
<form action="advs.php?c=1" method=POST> 
<b>Find Results with: </b><br> 
Any of these words: <input type="text" length=40 name="any"> <br> 
All of these words: <input type="text" length=40 name="all"> <br> 
None of these words: <input type="text" length=40 name="none"> <br> 
<input type="submit" value="Search"> 
</form> 
<? 
   } else if($c) { 
   MySQL_connect("localhost", "project1", "project01"); 
       MySQL_select_db("UPM2004c"); 
   if((!$all) || ($all == "")) { 
	$all = ""; 
   } else { 
	$all = "+(".$all.")"; 
   }if((!$any) || ($any == "")) 
   { $any = ""; 
   } if((!$none) || ($none == "")) { $none = ""; 
   } else 
   { $none = "-(".$none.")"; } 
   $query = " SELECT *, MATCH(username, password) AGAINST ('$all $none $any' IN BOOLEAN MODE) AS score FROM users WHERE MATCH(username, password) AGAINST ('$all $none $any' IN BOOLEAN MODE)"; 
      $artm1 = MySQL_query($query); 
      if(!$artm1) {  
         echo MySQL_error()."<br>$query<br>";  
      } 
      echo "<b>Article Matches</b><br>"; 
      if(MySQL_num_rows($artm1) > 0) { 
         echo "<table>"; 
          echo "<tr><td>Score </td><td>First</td><td>Last</td></tr>"; 
             while($artm2 = MySQL_fetch_array($artm1)) { 
            $val = round($artm2['score'], 3); 
            $val = $val*100; 
            echo "<tr><td>$val</td>"; 
            echo "<td>{$artm2['username']}</td>"; 
            echo "<td>{$artm2['password']}</td></tr>"; 
         } 
      echo "</table>"; 
   } 
   else {  
      echo "No Results were found in this category.<br>";  
   } 
   echo "<br>";  
   }
then the result is "The page cannot be found"... so what is my prob???

[Edit: Read: viewtopic.php?t=21171 --JAM]

Posted: Sat May 29, 2004 11:44 am
by Illusionist
i think it has to do with the '?c=1' in your form action... If you are using that, to check whether or not the from has been submitted, then there is a much easier and better way....

YOu can just check $_POST['submit'] (if you name your submit button 'submit')

You might not have register_globals on, and if you don't then your variables will not contain any data when you submit, either way i suggest using $_POST fo your post variables and $_GET for your get variable(from the url)