Click to See Complete Forum and Search --> : Worked Before But Not No More


Jick
07-25-2003, 11:54 AM
When you go to my site (http://kd7pyo.infinitypages.com/) you will see a search box at the bottom of the page. Try typing "dandy". It usally comes up with all the pages since every page on my site has the word dandy at least once. But now when you do it it comes back with the search results as "T" and I can't figure out why. Can someone go and try the search and see if you can figure out what is wrong? Thanks. :D

Here is my code for the actual search:
<?PHP
include ("../online.php");
?>
<html>
<head>
<title>The Dandy Group - Search</title>
<link rel="stylesheet" href="css.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style>
BODY {
scrollbar-face-color:#999900;
scrollbar-highlight-color:#000000;
scrollbar-3dlight-color:#CCCCCC;
scrollbar-darkshadow-color:#CCCCCC;
scrollbar-shadow-color:#000000;
scrollbar-arrow-color:#000000;
scrollbar-track-color:#CCCCCC;
}
A:hover {
color: 666600; font-family: Verdana
}
</style>
</head>

<body bgcolor="FFFFFF" text="000000" link="000000" vlink="000000" alink="000000" style="overflow-x: hidden;" topmargin="40" leftmargin="40">
<?

if($action == "search") {

include "config.php";
$filename = "$root/site.dat";

if(strlen($keyword) <= 3){
print "<p><b>Your keyword must be longer than 3 characters.<br><br><a href='javascript:history.back(1)'>Go Back</a></b>";
}
else{

function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}


$user = file("$filename");
$searching = count($user);
$lis = 0;
for($x=0;$x<sizeof($user);$x++) { // start loop, each line of file
$temp = explode("|",$user[$x]); // explode the line and assign to temp
$line[$x] = "$temp[0]|$temp[1]|$temp[2]|$temp[3]"; // create array of temp

$keyword = trim($keyword, " ");
$keywords = explode(" ", $keyword);


foreach ($keywords as $word){
if(stristr($temp[3], $word) || stristr($temp[0], $word)) {
$collect[$lis] = $line[$x];
$lis++;
}
}
}

$time = microtime();
$time = number_format($time,3);

if($lis > 0){
$list = array_values(array_unique($collect));
}
else $list = $collect;
//var_dump($list);


if(sizeof($list) != "0") {

//sort($keyword);
echo "<p style='margin-top: 1; margin-bottom: 1'><b>",sizeof($list),"</b> Search Result(s) Found For <b>$keyword</b></p></font><img src='/images/page_line.jpg' width='300' height='12'><br><br><br></p>";

for($y=0;$y<sizeof($list);$y++) {
$temp = explode("|",$list[$y]);
echo '<li><a href=',$temp[2],'><b>',$temp[0],'</a></b><br>',$temp[1],'<BR><font color=gray><small>',$temp[2],'</small></font><BR><BR>';
}
if($stats == true){
echo "<p style='margin-top: 1; margin-bottom: 1'><br><img src='/images/page_line.jpg' width='300' height='12'><br>Search executed in <b>$time</b> seconds.</p>";
}
}

else{
echo "<p>Sorry but we could not find any results for <b>$keyword.</b><br><br>";
if($stats == true){
echo "Search executed in <b>$time</b> seconds.<br><br><a href='javascript:history.back(1)'>Go Back</a>";
}
}

?>

<?
}
}
else if(!$action || $action == ""){
?>
<form action="<? echo ($_SERVER['PHP_SELF']); ?>" method="post">
Search:
<input type="text" name="keyword" size="20" maxlength="100">
<input type="submit" name="submit" value="Search">
<input type ="hidden" name="action" value ="search">
</form>
<?
}
?>
</body>
I would greatly appreciate any and all help any body can give me to help fix this problem that wasn't here before. I think I may have changed something accidently. :(

Jick
07-25-2003, 04:01 PM
This is urgent. I need help please. I need to get this fixed asap. :(

Kr|Z
07-27-2003, 04:17 PM
You search for a match in site.dat, right?

And site.dat looks something like:

Title|description|url|search words ?

I tried to copy your code and make a file like that.
I didnt have any problems with it, so I guess your problem
is in site.dat...