Greetings.
I have a project that takes user input via a standard html form, then queries another website using the information provided by the user, embedded in the URL.
This works great for single word queries, but any query with a space in it failes horribly. I have tried replacing spaces with %20 but these insertions don't work with the website I am attempting to Query. I have searched the forums here and other websites, and am at a complete loss. Yes, the multiple words do exist in the target location, and I can test it successfuly on the older versions.
has anyone else out there encountered this issue? A sample of the code follows:
$kount=$hits[0][$hit_count]; $keywordz=$phraze[0][$hit_count];
// Remember we have to clean the HTML tags off the last 4 chars of $keywordz
// We also need to be able to choose multiple words in the form submissions.
$keywordz=strrev($keywordz); $keywordz=substr($keywordz, 4); $keywordz=strrev($keywordz);
$keywordz=str_replace(" ", "%20", $keywordz); // Add %20 for URL
$loadurl="http://www.url.to.load.com?_function=available&desiredKeyword=".$keywordz;
$start=$keywordz."</b>"; $stop=100;
$availability = file_get_contents ($loadurl);
$start=strpos($availability, $start); $len=strpos($availability, $stop);
$quantas=substr($availability, $start, $stop);
$quantaz = explode(" ", $quantas);
// echo $quantaz[2];
$keywordz=str_replace("%20", " ", $keywordz); // remove %20 for display
echo "<tr><td>".$quantaz[2]."</td><td>".$kount."</td><td>".$keywordz."</td></tr>\n"; $hit_count++;
It's messy I know, I am just trying to get it to work, then I plan on cleaning it up.
Any Takers? Ideas?
2Hawks