Web Fetching Woes.....
Posted: Sat Mar 08, 2003 7:46 pm
This script that I wrote seems to be really buggy....
It is supposed to fetch latest lottery numbers from lottery.ca
I have also made it so that it takes the balls that I drew instead of lottery balls that they have.
It keeps giving me -462 as my output
, but it should really give me 6 images as output.
I ran out of ideas on what it could be.
I have tried just the $StartPos, $EndPos and $String part without all of the replacing and stuff, and it still gives me -462. I think that the problem is somewhere withing the $String function.
(But then again I am a newbie..... what do I know)
Any help would be greatly appreciated.
IcE.
It is supposed to fetch latest lottery numbers from lottery.ca
I have also made it so that it takes the balls that I drew instead of lottery balls that they have.
It keeps giving me -462 as my output
I ran out of ideas on what it could be.
I have tried just the $StartPos, $EndPos and $String part without all of the replacing and stuff, and it still gives me -462. I think that the problem is somewhere withing the $String function.
(But then again I am a newbie..... what do I know)
Code: Select all
$Lotto = array(
"../temp/lotto.cache",
"http://www.lottery.ca/nontariolot/n649/index.shtml",
"Bonus</small></font></td>",
"<td width="308" colspan="7"><hr color="#F8DB36" noshade>"
);
function StoreData ($file, $url, $start, $end) {
$time = split(" ", microtime());
$cache_time = filectime($file) + 10800;
if ($cache_time < $timeї1]) {
$fp = fopen($url,"r");
$ReadIn = fread($fp,100000);
$StartPos = strpos($ReadIn, $start);
$EndPos = strpos($ReadIn, $end);
$String = $EndPos - $StartPos;
$code = ereg_replace("http://www.lottery.ca/art/smballs/","images/blue/",$String);
$code = ereg_replace("http://www.lottery.ca/art/redsmballs/","images/red/",$String);
$fcache = fopen($file, "w");
fputs($fcache, $code);
fclose($fcache);
$final=$code;
} else {
$final=$ReadIn;
}
return $final;
}
$lottoStore = StoreData($file=$Lottoї0], $url=$Lottoї1], $start=$Lottoї2], $end=$Lottoї3]);
echo $lottoStore;IcE.