Hi.
I'm trying to merge a search engine xml feed with a local search.
Basically the feed allows for custom search variables.
The searchengine xml format is like this:
searchengine.com/?search=search+term+here
(seperating words with +)
I've added
$somesearch = $_REQUEST["somesearch"];
into the basic php example, so that
mydomain.com/magicparser.php?somesearch=searchterm
adds searchterm as the search parameter through $somesearch
And it works fine as long as I keep the searchterm to one word..
How do I carry the searchterm into the $url variable if the term consists of multiple keywords seperated by +
I've included the code below:
<?php
$somesearch = $_REQUEST["somesearch"];
header("Content-Type: text/html; charset=iso-8859-1");
require("MagicParser.php");
function myRecordHandler($record)
{
print "<h1>".$record["TITLE"]."</h1>";
print "<p>".$record["DESCRIPTION"]."</p>";
}
$url = "http://searchengine.com/?search=.$somesearch";
MagicParser_parse($url,"myRecordHandler","xml|More")
?>
I'm very new to php so this is probably a real dumb question..
Hi,
PHP's urlencode() function is what you need to do this, for example:
$url = "http://searchengine.com/?search=".urlencode($somesearch);
That should do the trick!
Cheers,
David.