PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Troubleshooting (http://www.phpdig.net/forum/forumdisplay.php?f=22)
-   -   Problem using custom search result page (http://www.phpdig.net/forum/showthread.php?t=1264)

passweb 09-02-2004 01:57 PM

Problem using custom search result page
 
Greetings,

I'm trying to fit PhpDig into my CMS. Right now the indexing is working perfectly, and my search.php works flawlessly. The problem, however, is that I am trying to use a php CMS I have developed to display the search results, not the original search.php script. When I do a search, my script (which is almost identical to the search.php one, except using an array rather than a template) says that there are no search results. search.php, on the other hand, gives me plenty of results. It's like it gives me different results depending on which php page is requesting it.
Here is the code for the page that is giving me problems (this code is stored in a database, then eval'ed by my CMS):
PHP Code:

<?php
if (isset($_REQUEST['query_string'])) {
$relative_script_path './phpdig';
$no_connect 0;

if (
is_file("$relative_script_path/includes/config.php")) {
    include 
"$relative_script_path/includes/config.php";
}
else {
    die(
"Cannot find config.php file.\n");
}

if (
is_file("$relative_script_path/libs/search_function.php")) {
    include 
"$relative_script_path/libs/search_function.php";
}
else {
   die(
"Cannot find search_function.php file.\n");
}

// extract vars
extract(phpdigHttpVars(
     array(
'query_string'=>'string',
           
'refine'=>'integer',
           
'refine_url'=>'string',
           
'site'=>'string'// set to integer later
           
'limite'=>'integer',
           
'option'=>'string',
           
'lim_start'=>'integer',
           
'browse'=>'integer',
           
'path'=>'string'
           
)
     ));

$search=phpdigSearch($id_connect$query_string$option$refine,
              
$refine_url$lim_start$limite$browse,
              
0$path$relative_script_path'array','');

if (
strtolower($search[result_message]) != 'noresults') {
  
$results $search[results];
  unset(
$search[results]);
  
$nav_bar str_replace('search.php?','./?id=new_search&',$search[nav_bar]);
  echo(
'<div align="center"><strong>'.$search[result_message].'</strong><br/>'.$nav_bar.'</div>');
  echo(
'<table class="searchTable">');
  foreach(
$results as $x)
  {
    
// this checks for binary data, and fixes the name so it looks like
    
$name $x[link_title];
    if ( 
substr($name,0,14)=='binarydata.php')
    {
      
$loc_f strpos($name,"&n=")+3;
      
$filename urldecode(substr($name,$loc_f,strlen($name)-$loc_f));
      
$loc_id strpos($name,"?id=")+4;
      
$fid substr($name,$loc_id,$loc_f-$loc_id-3);
      
$name $fid ": " .$filename;
      echo(
'<tr><td class="searchTitle"><a href="./?id='.$fid.'">'.get_frame_title($fid).'</a> : <a href="'.$x[complete_path].'">'.$filename.'</a> ('.$x[weight].')</td></tr>');
    } else { 
// ok its a real page, not binary data
      
echo('<tr><td class="searchTitle"><a href="'.$x[complete_path].'">'.$name.'</a> ('.$x[weight].')</td></tr>');
    }
    echo(
'<tr><td>'.preg_replace('/('.preg_quote($query_string).')/i','<span style="color: Red;">1</span>'$x[text]).'</td></tr>');
    echo(
'<tr><td> </td></tr>'); // spacer row
  
}
  echo(
'</table><br />');
  echo(
'<div align="center">'.$nav_bar.'</div>');
} else {
  echo(
'Sorry, there were no results for your search. Please refine your query.');
}


} else {
echo(
'No search terms specified.');
}
  
?>
<br />
<br />
<div align="center">Uses <a href="http://www.phpdig.net/">PhpDig</a> Search Technology</div>

Any help would be greatly appreciated. :) I've followed the examples and instructions that were in a number of threads here, so I think I've modified things so that it should work by now.

(I think I've fixed the paths, which were earlier giving me trouble... right now the dir structure looks like:

/default.php (which takes ?id= and presents whichever page in the cms was requested, eg: default.php?id=search_results)
/search.php (which I wish to not have to use but is still working)
/phpdig/ (the phpdig dir)

Charter 09-07-2004 03:42 PM

Hi. What is the exact message you receive?

passweb 09-13-2004 01:02 PM

Quote:

Originally Posted by Charter
Hi. What is the exact message you receive?

Quote:

Sorry, there were no results for your search. Please refine your query.
is what is returned.

Charter 09-13-2004 01:18 PM

In the language pack is 'noresults' =>'No results' so try changing if (strtolower($search[result_message]) != 'noresults') to if (strtolower($search[result_message]) != 'no results') and see if it works.

passweb 09-13-2004 02:44 PM

Quote:

Originally Posted by Charter
In the language pack is 'noresults' =>'No results' so try changing if (strtolower($search[result_message]) != 'noresults') to if (strtolower($search[result_message]) != 'no results') and see if it works.

Thanks for the quick reply! Unfortunately, that did not work. :( The $search[result_message] is 'noresults' with no space. Any other ideas?

Charter 09-13-2004 10:43 PM

It would seem then that if (strtolower($search[result_message]) != 'noresults') or rather $search[result_message] is always being returned as 'noresults' a check of whatever mods you made to the search_function.php file might lend a clue.


All times are GMT -8. The time now is 08:32 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.