Jump to content

unset $_GET


bschultz

Recommended Posts

I have a search box on a site that searches the database for similar items.  When you call the search page for the first time...everything works great.  However, if you search FROM WITHIN the search page...it returns EVERY item in the database....not just those that match.

 

In searching for solutions, I've seen that you can't unset a $_GET variable.  I've tried unset($GLOBALS); and that didn't work either.

 

Any ideas?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/208492-unset-_get/
Share on other sites

<?php
$search_word = $_GET[keyword];

///////////////////////  SEARCH KEYWORDS HERE   ///////////////////////
$link = mysql_pconnect($host, $username, $password);  
mysql_select_db('northwoo_allconten',$link);
$sql = "SELECT * FROM stories WHERE (station = 'mix' OR station = 'all') AND (headline LIKE '%$search_word%' OR long_story LIKE '%$search_word%')";
//$sql = "SELECT * FROM stories WHERE (station = 'mix' OR station = 'all') AND (headline LIKE '%$_GET[keyword]%')";

$rs = mysql_query($sql,$link);  
$matches = 0; 
echo "<h3>Here are the results of your search...</h3>";
while ($row = mysql_fetch_assoc($rs))  {
$matches++;
echo "<div class='left_box'>";
$headline = str_replace('COMPANYNAMEHERE',COMP_NAME,$row['headline']);
echo "<h3>$headline</h3>";
echo "<div class='left_img_box'>$row[short_story_image]</div>";
echo "<div class='left_text_content'><p>";
$code2 = str_replace('COMPANYNAMEHERE',COMP_NAME,$row['short_story']);
eval('?>' . $code2 . '<?');
echo "</p></div></div>";
}  
if (! $matches) { 
echo ("No matches for search term '$_GET[keyword]'...please try again.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"); 
}  
echo ""; 
unset($GLOBALS); 

?> 

Link to comment
https://forums.phpfreaks.com/topic/208492-unset-_get/#findComment-1089383
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.