mastercool Posted December 23, 2008 Share Posted December 23, 2008 I recently moved my entire site from one web host to another. The search function had worked previously but now that it has been moved it doesn't seem to work. It goes through the search but then says the keyword isn't found. Below is the code, any help would be appreciated. Thanks. <?php $keyword = $found = $count = $file = $filescope = 0; $titl = array(); $keyword = @$HTTP_GET_VARS['keyword']; if ($keyword and strlen($keyword) > 2) : ?> <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr height="23"> <td align="center" width="20" height="23"></td> <td align="center" width="2" height="23"></td> <td align="center" height="23"> <div align="left"> <font size="2" color="black" face="Arial, Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">search result(s) for word:</font> <b><?php echo $keyword ?></b></div> </td> </tr> <tr> <td colspan="3" height="2"></td> </tr> <tr> <td></td> <td colspan="2"><font size="2" face="Arial, Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">found on page(s)</font></td> </tr> <?php if(!isset($_SERVER["DOCUMENT_ROOT"])) { $_SERVER["DOCUMENT_ROOT"]=substr($_SERVER['PATH_TRANSLATED'] , 0 , 39 ); } $DOCROOT = $_SERVER['DOCUMENT_ROOT']; //echo $DOCROOT; //echo $_SERVER["DOCUMENT_ROOT"]; //echo $_SERVER['PATH_TRANSLATED']; //echo "test"; //echo $_SERVER['PHP_SELF']; $patch=opendir($DOCROOT); while($file = readdir($patch)) : $tmpfile = $DOCROOT . $file; if (is_file($tmpfile) and preg_match("/.*\.html/i", $tmpfile)){ $fop = fopen($tmpfile, "r"); $search = fread($fop, filesize($tmpfile)); fclose($fop); $filecope2 = $search; $search = preg_replace("/<option.*>(.*)\n/i", "", $search); $search = strip_tags($search, "<title>"); $filecope = $search; if (preg_match("/\s($keyword)\s/i", $search, $result)) { // echo $result[1];/\<title\>(+*)\</i if (!$found) { $found="yes"; } preg_match("/<title>(.*)/i", $filecope2, $result); ?><!-- --> <tr> <td colspan="3" height="6"></td> </tr> <tr> <td class="count" align="center"><?php $count++; echo $count; ?></td> <td></td> <td> <a href="<?php echo $file ?>"><?php echo $result[1]; ?></a></td> </tr> <tr> <td colspan="3" height="6"></td> </tr> <?php } } endwhile; closedir($patch); if (!$found) : ?> <tr> <td colspan="3" height="5"></td> </tr> <td colspan="3"> <div align="center"> <b>The required word is not found</b></div> </td> </table> </td> </tr> <?php endif; ?> Quote Link to comment https://forums.phpfreaks.com/topic/138184-php-search/ Share on other sites More sharing options...
ngreenwood6 Posted December 23, 2008 Share Posted December 23, 2008 you should use code tags. the reason you are probably getting that is because $HTTP_GET_VARS['keyword']; has been depreciated. You may want to try this: $keyword = $_GET['keyword']; Quote Link to comment https://forums.phpfreaks.com/topic/138184-php-search/#findComment-722347 Share on other sites More sharing options...
mastercool Posted December 23, 2008 Author Share Posted December 23, 2008 Thank you for the advice, unfortunately that isn't it. Could it have something to do with the new server that I am on. I just find it weird that everything worked before I moved it over. Quote Link to comment https://forums.phpfreaks.com/topic/138184-php-search/#findComment-722388 Share on other sites More sharing options...
premiso Posted December 23, 2008 Share Posted December 23, 2008 Chances are the new server as register_globals off. You need to code for that as it was a security flaw. Also note that $HTTP_GET_VARS is depreciated. Any instance should be changed to $_GET, same with $HTTP_POST_VARS should be $_POST. Quote Link to comment https://forums.phpfreaks.com/topic/138184-php-search/#findComment-722407 Share on other sites More sharing options...
ngreenwood6 Posted December 23, 2008 Share Posted December 23, 2008 Thank you for the advice, unfortunately that isn't it. unfortunately just saying that and not trying it doesn't actually help your case, I was getting at what premiso said and if your server has register_globals off then you can have them "try" to have them turn it on but it is not recommended. Quote Link to comment https://forums.phpfreaks.com/topic/138184-php-search/#findComment-722507 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.