Warning: eregi(): REG_EMPTY
Posted: Thu Apr 13, 2006 3:35 am
I'm kinda new with this whole PHP thing, and i'm currently making an internal search engine for a website. Actually I followed a tutorial on it and wrote the whole thing according to plan.. But when i finally tried the thing it wouldn't work.
Here's what i get when i search for something:
Warning: eregi(): REG_EMPTY in /home/prexide/public_html/screwcork/TCS/search.php on line 25
Warning: eregi(): REG_EMPTY in /home/prexide/public_html/screwcork/TCS/search.php on line 25
No result No result
and here's the code i use in full:
Please help a newb!
Here's what i get when i search for something:
Warning: eregi(): REG_EMPTY in /home/prexide/public_html/screwcork/TCS/search.php on line 25
Warning: eregi(): REG_EMPTY in /home/prexide/public_html/screwcork/TCS/search.php on line 25
No result No result
and here's the code i use in full:
Code: Select all
<?php
set_time_limit("600");
$keyword=trim($_POST["keyword"]);
if($keyword==""){
echo"Please enter your keyword";
exit;
}
function listFiles($dir,$keyword,&$array){
$handle=opendir($dir);
while(false!==($file=readdir($handle))){
if($file!="."&&$file!=".."){
if(is_dir("$dir/$file")){
listFiles("$dir/$file",$keyword,$array);
}
else{
$data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));
if(eregi("]+)>(.+)",$data,$b)){
$body=strip_tags($b["2"]);
}
else{
$body=strip_tags($data);
}
if($file!="search.php"){
if(eregi("$keyword",$body)){
if(eregi("",$data,$m)){ //this is the line who bugs my brain!!!
$title=$m["1"];
}
else{
$title="No result";
}
$array[]="$dir/$file $title";
}
}
}
}
}
}
$array=array();
listFiles(".","$keyword",$array);
foreach($array as $value){
list($filedir,$title)=split("[ ]",$value,"2");
echo "$title "."
\n";
}
?>