ksteuber Posted October 21, 2006 Share Posted October 21, 2006 Ok, somebody must have asked this question before, but I can't find it.I'm using PHP 4.3.11, and I'm in the middle of writing a page that retreives other pages and displays them.The problem I'm having is that after it gets the page and makes some changes to it, the script is supposed to display the whole page, then save a copy of it to the server as shown in the excerpt of code below:[code]echo $done; //$done is the variable that has site stored to it.$fp = fopen("/home/content/k/s/t/ksteuber/html/php_uploads/logs/".$URL." - ".date("F j, Y, g:i a"),"w");fwrite($fp,$done);fclose($fp);[/code]Very, very straight forward. However, it only shows about half of the page, and doesn't write any file, so I can only assume that the script just stops halfway through the command. I thought it might be a time issue, but the page takes 1.320 sec to load from when I send the request for the page to when I recieve it, and the script claims that it has spent 0.450 sec up to the point that it sends the file (I believe scripts have a 30 sec timeout, not .5 sec) Does anybody know why the script would just stop?Note: The result of the script can be found by going to [url=http://www.kirksteuber.com/]http://www.kirksteuber.com/[/url] and clicking on "In page proxy"The full text of the code can be found at [url=http://www.kirksteuber.com/parser.txt]http://www.kirksteuber.com/parser.txt[/url] Quote Link to comment Share on other sites More sharing options...
ksteuber Posted October 28, 2006 Author Share Posted October 28, 2006 Does anybody know?Shouldn't there be an easy solution? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 28, 2006 Share Posted October 28, 2006 Are you sure the fopen() works. It will return 'false' if it fails.Have you checked the content of the file you are reading into the $done variable immediately after the point at which it stops. eg is there a < with no closing > so nothing is displayed? Quote Link to comment Share on other sites More sharing options...
ksteuber Posted October 29, 2006 Author Share Posted October 29, 2006 as for fopen, I have no way of knowing if it works, since the script doesn't even get past the echo command (it desplays a portion of $done, and not the rest of it, and I have tried but I can't get any other funtions that I use after "echo $done;" to give me a sign that it has been executed at all)as for the second idea, I have been looking at the source after I run the script, so I would see any abnormally long tags. Quote Link to comment Share on other sites More sharing options...
pendelton Posted October 29, 2006 Share Posted October 29, 2006 Does the file already exist and is the file/folder on the server writeable? Also, try setting $done to a simple string like "hello" until you get things working. Quote Link to comment Share on other sites More sharing options...
ksteuber Posted October 29, 2006 Author Share Posted October 29, 2006 Ok, so I tried the $done="hello"; idea, which made it so that the script would return a fopen error which turned out to be because $URL contained "http://" and "/" is a forbidden character in linux filenames. (Oops, thats an embarassing mistake)I changed the code to:[code]echo $done;$filename = "/home/content/k/s/t/ksteuber/html/php_uploads/logs/".substr($URL,7)." - ".date("F j, Y, g:i a");$fp = fopen($filename,"w");fwrite($fp,$done);fclose($fp);[/code]Now it makes the file properly, and the file contains the entire site (Yay). However, "echo $done;" still is not working properly. When I view the webpage, I still get only a fraction of $done.I also tried to export some different text at that point in the script that was the same length as $done would have been, but that didn't work either.But wait, here's the weird part. If I make a completely different script that echos that much info, but doesn't execute any of the other commands in the original script, it works. So presumably there is something else in the script that is interfering with the echo command. (The full code of the script is still at: http://www.kirksteuber.com/parser.txt) Quote Link to comment Share on other sites More sharing options...
pendelton Posted October 29, 2006 Share Posted October 29, 2006 Are you saying that you echo doesn't work when you output the content of a file? If so, don't forget that you are viewing it via HTML which will format the output (or at least probably get confused by some of your file format). Get your echo to echo's the file content that doesn't quite work then do view source on the page. You should find that it is all there in the source but isn't all displayed as you expect in the broweser. Quote Link to comment Share on other sites More sharing options...
ksteuber Posted October 30, 2006 Author Share Posted October 30, 2006 ksteuber:[quote]...I have been looking at the source after I run the script...[/quote] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.