Jump to content

PHP pages not fully loading


aspnetguy

Recommended Posts

here is a bit of background info on the situation. I am running the code on Apache 2.0.58 with PHP 5.1.4 and I have MySql 4.1I have written a script that displays the contents of my server and allows me to edit php files in my browser.The script runs perfectly on localhost. But if I get up and walk over to my other PC and use 192.168.0.101/scriptName instead The script only displays some of the files in the list...gets to a certain point int he list and then just stops...html is incomplet and occasionally I get weird text symbols on the page.I tried using a pre-made script off the internet witht he same results. If I refresh the page sometimes I get more of the list and sometimes less and about every 1 in 100 I get the full list.I have also tested a similar script written in ASP.Net on this same setup with no problems at all.So it must be something about my PHP configuration right? Why is it not passing (or amybe not creating) the full html the script should?

Link to comment
Share on other sites

That's strange.. I assume it's not timing out or anything like that, you don't see any error messages, right? The only thing I can think to try is to test it on other setups and try to determine what the problem is. I have IIS5/PHP4 set up at home, if you want to post the code or PM me or something I'll be happy to test it out.If you have any web servers online, maybe try it there. I have a few servers with various hosts I can test it on as well.

Link to comment
Share on other sites

I was able to test it out, and it looks fine. None of the functions are working, the edit doesn't show the code in the text box (some code appeared below it), and things like the delete and upload aren't working, but I can browse the directories, and get the file upload boxes at the bottom. I couldn't test it at home because I don't have PHP 5 here, but I was able to test it on another server and it looked fine, it was quick too. The server it was running on was running Windows Server 2003 with IIS6, and I was connected to the server through Terminal Services and running it locally.I was looking through the documentation for scandir, which seems to be what requires PHP 5, and I found this function to add it to PHP 4:

if(!function_exists('scandir')){   function scandir($dir, $sortorder = 0)   {	   if(is_dir($dir))	   {		   $dirlist = opendir($dir);		   		   while( ($file = readdir($dirlist)) !== false)		   {			   if(!is_dir($file))			   {				   $files[] = $file;			   }		   }		   		   ($sortorder == 0) ? asort($files) : arsort($files);		   		   return $files;	   }	   else	   {	   return FALSE;	   break;	   }   }}

So, I added that to the code and tested it at home at it still worked. At home the server is running Windows XP Pro with IIS5.I came back and re-read your post here, and noticed that I was testing on the first server with localhost in the URL. I re-uploaded it to the server, and then tested it remotely from home, and it was still working. It looks like that server is running PHP 5.0.4. At home where it was working I was accessing the server across a LAN by computer name.So. I'm not sure where that leaves us. If it is working on your server when using localhost, maybe try it on the same server with the IP or computer name instead and see if you get anything different. But if it is working at all, that tells me that PHP is not the problem. I'm sort of suspecting that Apache may be to blame, Apache may do something different for localhost vs. remote. This may be a headache to accomplish, but if you can set up IIS on the same machine and install the same version of PHP to work with it, and then disable Apache and test it with IIS, I would be interested to see what happens. I doubt it is the version of PHP, I did not see any notes on the documentation page for scandir from anyone complaining that it wasn't working. All of the notes on the page are user-contributed functions.Oh, one thing to note would be that apparently the end of the file got cut off somehow, either in your PM or when I sent it to myself by email. This was the end of what I saw on the page:

<?php if($EDIT_FILE){ ?> <div id="editFile"> <div class="fileName"><input type="text" name="filename" id="filename" value="<?php echo $file; ?>" size="25"/></div> <div class="fileContents"><textarea name="filecontents" id="filecontents"><?php echo $file_contents; ?>

Followed by a warning generated by Opera, which I use for email, about not being able to properly decode the file. I added a closing bracket for the if statement, and now that I look at it, that's obviously the reason why the file contents weren't in the textbox, the ending textarea tag is not there. But even with the file ending at that point, it was still working. I doubt this has anything to do with the problem, but maybe add the closing bracket where I did like this:

<?php if($EDIT_FILE){ ?> <div id="editFile"> <div class="fileName"><input type="text" name="filename" id="filename" value="<?php echo $file; ?>" size="25"/></div> <div class="fileContents"><textarea name="filecontents" id="filecontents"><?php echo $file_contents; ?><?php } ?>

followed by an exit();I doubt if that will suddenly make it work, I'll be shocked if it does. But if it does, then apparently the problem is below that point.*I went back and checked the PM, and the code did stop after the textarea tag

Link to comment
Share on other sites

  • 2 weeks later...

thanks for testing it...I suspect it was apache as well...it worked fine on another server.I know that alot of the functions weren't working. I was still trying to figure out why I couldn't view it properly remotely. I am now on IIS6 so that takes car of the problem. I have a pre-made PHP4 script (went back to PHP4 from 5) and all is fine.Thanks for your help.

Link to comment
Share on other sites

  • 7 months later...

wow, I'm digging up an oldy but I finally figured out the cause of this and how to fix it because it happened again today. What lead me to the solution this time was the newest version of phpMyAdmin. Back when I first posted this phpMyAdmin didn't throw any errors, it just rendered weird. This version sent out some errors instead. Turns out that if the mbstring and mcrypt extensions are not available strings get parsed incorrectly (in Wordpress and phpMyAdmin) giving the strange results I had. After enabling those extentions everything was fine.This time and last time I was working with a fresh install of php5 and had forgot to enable some extensions.Hope this might save someone else some grief.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...