The script below is supposed to display Ebay search results. Can anyone tell be why the results are always blank. If I run the plain search string in my browser, I get the right Ebay results page. However, the script won't print the results the way its supposed to.
<?
set_time_limit(36000);
#Which ebay site do you want to search?
#Valid values are .com - .co.uk - .de - .fr - If I've missed any others,
#you may insert them yourself but ALWAYS start it with a period!
$ebaysite = ".com";
$headerfile = "header.php";
$footerfile = "footer.php";
$thisfile = "index.php";
$tablewidth = "100%";
$searchtext = "Search eBay: ";
$searchbtntext = "Go!";
$searchtxtcolor = "#0000FF";
$resultsheadbgcolor = "#000099";
$resultsheadtextcolor = "#FFFFFF";
$resultsbgcolor1 = "#DDDDDD";
$resultsbgcolor2 = "#EEEEEE";
$resultstextcolor = "#000000";
$fontface = "Verdana";
$siteid = "1345673";
$newwin = 0;
if ($headerfile) include $headerfile;
if ($newwin) print "<base target='_sresult'>\n";
print "<div align='center'><form name='form1' method='get' action='$thisfile'>
<b><font color='$searchtxtcolor' face='$fontface'>$searchtext</font></b>:
<input type='text' name='search'>
<input type='submit' name='Submit' value='$searchbtntext'>
</form></div>";
if($search) {
$q = urlencode($search);
$page = join("", file("http://search.ebay".$ebaysite."/search/search.dll?MfcISAPICommand=GetResult&ht=1&shortcut=4&SortProperty=MetaEndSort&maxRecordsPerPage=50&st=2&ebaytag1code=77&query=".$q));
$page = ereg_replace("\n", "", $page);
$reg = "/<table width=\"100%\" cellpadding=\"3\" border=\"0\" cellspacing=\"0\" bgcolor=.*?>(.*?)<\/table>/";
preg_match_all($reg,$page,$matches);
$num = count($matches[0]);
print "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'><tr bgcolor='$resultsheadbgcolor'><td width='66%' align='center' valign='top'><font face='$fontface' size='-1'><b><font color='$resultsheadtextcolor'>Item Title</font></b></font></td><td width='10%' valign='top' align='center'><font face='$fontface' size='-1'><b><font color='$resultsheadtextcolor'>Price</font></b></font></td><td width='7%' align='center'><font face='$fontface' size='-1'><b><font color='$resultsheadtextcolor'>Bids</font></b></font></td><td width='17%' valign='top' align='right'><font face='$fontface' size='-1'><b><font color='$resultsheadtextcolor'>Time Left</font></b></font></td></tr></table>";
$rowcolor = $resultsbgcolor1;
for ($x=0;$x<$num;$x++){
$entry = $matches[1][$x];
if ($rowcolor==$resultsbgcolor1){
$rowcolor = $resultsbgcolor2;
}
else
{
$rowcolor = $resultsbgcolor1;
}
if ($newwin) $targetwin = " target='other'";
$entry = str_replace("http://cgi.ebay", "http://www.qksrv.net/click-$siteid-5463217?loc=http%3A//cgi.ebay", $entry);
$entry = str_replace("eBayISAPI.dll?ViewItem&item=", "eBayISAPI.dll%3FViewItem%26item%3D", $entry);
$entry = str_replace("%26category%3D", "&category=", $entry);
print "<table width='$tablewidth' cellpadding='3' border='0' cellspacing='0' bgcolor='$rowcolor'>".$entry."</table>\n";
}
}
if ($footerfile) include $footerfile;
?>