|
-
Feb 1st, 2003, 10:57 AM
#1
Thread Starter
Lively Member
Showing some result while waiting for socket connection
PHP Code:
$host = "www.yahoo.com";
$fp = fsockopen($host,80);
//some http-connection stuff
while (!feof($fp))
echo "getting site";
$buf .= fgets($fp,128);
fclose($fp);
echo $buf;
Problem with this is that it prints "getting site" a million times
untill the socket is finished How can I make it print it only 1 time
on the page? Also, how can I "clear" the page afterwards so just
the result is shown?
-
Feb 1st, 2003, 03:23 PM
#2
Frenzied Member
that is because you have it in a loop, take it out of that loop and put it before or after the while, my guess is that you need it before the loop. then when done just load a different page.
-
Feb 2nd, 2003, 07:52 AM
#3
Thread Starter
Lively Member
Dont think you quite understood what I wanted to do But I kind
of solved it. Just loaded a page with meta-refresh first. Doesn't
do exactly what I wanted, but better than nothing
-
Feb 2nd, 2003, 12:03 PM
#4
Frenzied Member
umm yes I did, you say it was printing "getting site" a million times, well take it out of the loop and it will stop.
while (!feof($fp))
echo "getting site"; // inside the while loop
$buf .= fgets($fp,128);
fclose($fp);
so then to print it once you do this
echo "getting site";
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
then it will only print that line and the results, no need to reload a page. hmmm sounds easy to me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|