Forum Moderators: coopster

Message Too Old, No Replies

parsing CGI result in PHP

parsing CGI search script result in PHP - Somtime works and sometime not !

         

fastfriend

1:13 pm on Feb 22, 2006 (gmt 0)

10+ Year Member



I have installed Smart Search Script on my domain. The main file smartsearch.cgi shows result perfectly if I run this CGI directly.

I want to show the results of smartsearch.cgi in my PHP page.

I have tried different options such as require, include, implode etc. All works sometimes and sometimes not.

I mostly tried with include and the code is as follows:

$keywords = $_GET['keywords'];

$search_n = (include ("http://mydomainxyz.com/cgi-bin/search_n/smartsearch.cgi?keywords=$keywords"));

$search_f = include ("http://mydomainxyz.com/cgi-bin/search_f/smartsearch.cgi?keywords=$keywords");

echo "$search_n";
echo "$search_f";

I have also tried with PATH rather URL but it works sometimes and sometimes not.

The error I got is from ERROR LOG.

PHP Warning: main(): Failed opening 'http://mydomainxyz.com/cgi-bin/search_n/smartsearch.cgi?keywords=abc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php')

[22-Feb-2006 08:38:12] PHP Warning: main(http://mydomainxyz.com/cgi-bin/search_f/smartsearch.cgi?keywords=abc): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
in /home/#*$!xx/public_html/search/search.php on line 7

Any Help will be highly appreiated.

coopster

6:01 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



See that '400 Bad Request' response? I'm guessing your QUERY_STRING, which is your $keywords variable, is your issue. You should make the keywords into a valid "name=value" string first, then urlencode [php.net] it.