PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Tue Jan 06, 2004 2:06 am
i have this code :
Code: Select all
<?php
$handle = fopen ("http://www.bankisrael.gov.il/eng.shearim/index.php", "rb");
$contents = "";
while (!feof($handle)) {
$data = fread ($handle, 1024);
$contents .= $data;
//echo $contents;
}
fclose ($handle);
?>
when i tried to use it yesterdya for some reason i thonk there was a problem on the web site i was reading the page
beacuse of that in some point the apache.exe gave me FATAl error!!!!!
and the apache has crashed!
how can i prevent it?
thanks in advance
peleg
xisle
Forum Contributor
Posts: 249 Joined: Wed Jun 25, 2003 1:53 pm
Post
by xisle » Tue Jan 06, 2004 2:01 pm
just
to output each line of the file.
By appending to the $contents you are reprinting everything up to that line on each line, thus overflowing.
your script is doing something like this...
Code: Select all
echo line1 text;
echo line1 text;
echo line2 text;
echo line1 text;
echo line2 text;
echo line3 text;
echo line1 text;
echo line2 text;
echo line3 text;
echo line4 text;
if you want the entire file in one string than do this...
Code: Select all
$data=file($filename);
$outputstring=implode($data, "");
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Wed Jan 07, 2004 1:03 am
with $data i just read line by line the file!
xisle
Forum Contributor
Posts: 249 Joined: Wed Jun 25, 2003 1:53 pm
Post
by xisle » Wed Jan 07, 2004 4:13 pm
nO sh!T !! :LOL: