zipp Posted March 14, 2008 Share Posted March 14, 2008 Hello, here is what I am trying to do: use curl to get info from page2.php that is running the script: <? $i=0; while($i < 100){ $i++; sleep(1); echo $i." "; flush(); ob_flush(); } ?> (Thank you l0ve2hat3 : ) I need the page1.php to update as page2.php updates. Is there any way to do this? Link to comment https://forums.phpfreaks.com/topic/96076-curl/ Share on other sites More sharing options...
l0ve2hat3 Posted March 14, 2008 Share Posted March 14, 2008 wait why? Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491838 Share on other sites More sharing options...
zipp Posted March 14, 2008 Author Share Posted March 14, 2008 Just to learn, and see if it is actually possible. Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491839 Share on other sites More sharing options...
zipp Posted March 14, 2008 Author Share Posted March 14, 2008 Is there a way to do it with includes? maybe? Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491902 Share on other sites More sharing options...
Northern Flame Posted March 14, 2008 Share Posted March 14, 2008 yea what you're trying to do really doesnt make sense, cURL() is more for posting data and other stuff. what you are trying to do can be done by either including that file or just simply writing that code in page1.php Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491915 Share on other sites More sharing options...
zipp Posted March 14, 2008 Author Share Posted March 14, 2008 page1 and page2 will eventually be on different servers. right now im playing with readfile() and see if i can get it to work with that. Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491918 Share on other sites More sharing options...
Guest Posted March 14, 2008 Share Posted March 14, 2008 Here's my interpretation. You want page1.php to continually add the output of page2.php onto page1. If that's what you want, there's no "proper" way to do it with PHP alone. If you include it or even do readfile (btw, readfile will get you the code, not the result of the code) it won't update continuously. It'll just take its time, finishing the loop, before the user sees anything (unless you have output buffer off, or you're forcing the output buffer to flush, which you are). But it will NOT continue to load the rest of the page until that code is done. And my assumption is you want page2.php to run independently of page1. Let me try to summarize it (in case the above is confusing): you want page1 to load completely, done, and for it to load the result of page2 somewhere into page1 continually. I hope I'm not being confusing. Anyway. The best way you may want to approach this is a mix of PHP and javascript/AJAX. Use AJAX to continually poll page2.php and print the result into page1.php. Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491920 Share on other sites More sharing options...
zipp Posted March 14, 2008 Author Share Posted March 14, 2008 The best way you may want to approach this is a mix of PHP and javascript/AJAX. Use AJAX to continually poll page2.php and print the result into page1.php. I was afraid it would be something like that. Could you point me to a good tutorial, or supply a script of something similar? Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491923 Share on other sites More sharing options...
Guest Posted March 14, 2008 Share Posted March 14, 2008 You'll want to start ground up with Javascript and AJAX. If you're adept in PHP, javascript should come to you fairly quickly. You don't even need to take on javascript entirely to grasp AJAX. But I'd suggest it. If the page2.php you provided is all you want it to do, you can just do that in javascript without PHP at all. Good PHP/AJAX tutorial: http://www.ajaxf1.com/tutorial/ajax-php.html Other references: Javascript Tutorials: http://www.tizag.com/javascriptT/ AJAX tutorials http://www.tizag.com/ajaxTutorial/ Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491938 Share on other sites More sharing options...
zipp Posted March 14, 2008 Author Share Posted March 14, 2008 I decided to try something crazy, and echo an iframe with src of page2... Unfortunately it screws up my page 2 output. Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491961 Share on other sites More sharing options...
Guest Posted March 14, 2008 Share Posted March 14, 2008 Very clever, theoretically that should work. What's the problem? And if you fix it, do share. Although, I'm not much of a fan of iframes, but where it works, it works, no? Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491965 Share on other sites More sharing options...
zipp Posted March 14, 2008 Author Share Posted March 14, 2008 I'm not a big fan of frames either, but I'm trying all my options here. What i am actually making is... not sure what you would call it... it pings a server 10 times, then averages the pings to get the "average ping time"... the first ping always works... here is what it looks like 0.0607 seconds <-- normal 0.0057 seconds <-- crazzy 0.0577 seconds <-- normal 0.0041 seconds <-- crazzy 0.0034 seconds <-- crazzy etc... So I'm completely loss on this... It only stopped working when I started using iframes. Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491974 Share on other sites More sharing options...
zipp Posted March 14, 2008 Author Share Posted March 14, 2008 0.0793 seconds 0.0736 seconds 0.0701 seconds 0.0714 seconds 0.0634 seconds that is what i get without using iframes... all normal responses. Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-491983 Share on other sites More sharing options...
zipp Posted March 15, 2008 Author Share Posted March 15, 2008 Anyone have any ideas?? Everything works fine, except for this part Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-492730 Share on other sites More sharing options...
zipp Posted March 15, 2008 Author Share Posted March 15, 2008 how many ways r there to read a file? curl readfile fopen html frames any others? (is there an edit button?) Link to comment https://forums.phpfreaks.com/topic/96076-curl/#findComment-492768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.