At work I have a few servers I've been testing some PHP code on. One server is running Windows XP with Apache 2.2.14 with PHP 5.3.1.
When I access the site from my CentOS Server with Firefox 3.0.x, the PHP code doesn't execute on the Windows server and Firefox asks me to download the PHP file. But on the same box, I can use w3m (text only browser) and it works fine. And the same site works on all the other PCs I've tested it on. It just won't work on Firefox 3.0.x on the CentOS box.
All other PHP pages work on that box too. I've never seen that problem browsing the web with it, and it even hosts it's own copy of the same PHP code that the Windows server has which also works. And I have a third server running Windows XP (my desk computer) which also works fine with that CentOS box.
Thanks to anyone who can figure this out, I was ready to pull my hair out yesterday.
Sounds like it is the browser that does it wrong?
The file you can download, what does it contain? The sourcecode of your php file or what it outputs?
[QUOTE=Nisd;20196285]Sounds like it is the browser that does it wrong?
The file you can download, what does it contain? The sourcecode of your php file or what it outputs?[/QUOTE]
It was downloading the PHP source code.
[QUOTE=PvtCupcakes;20196589]It was downloading the PHP source code.[/QUOTE]
It actually downloads the source itself? That's fucked, normally when PHP files 'download' you get a blank file.
I know sometimes when I view pages on my site it'll try and "download" them instead. I eventually figured out this was because IE (which I was using to test the site at the time) didn't support the mime-type header I was sending so it decided it would assume I wanted to save the page instead of viewing it. I eventually got around that by checking the user-agent first then specifying the content-type, but it never sent the actual PHP source so I don't know why that'd be happening for you. Sounds like some kind of server mis-configuration.
Compare the headers the clients send.
Sound like you "hit" the wrong server? A probaly setup server would never output the source code.
Do you use DNS or ip to connect?
[QUOTE=Nisd;20207915]Sound like you "hit" the wrong server? A probaly setup server would never output the source code.
Do you use DNS or ip to connect?[/QUOTE]
I was using the IP.
[editline]02:23PM[/editline]
[QUOTE=DrTaxi;20207017]Compare the headers the clients send.[/QUOTE]
What? How?
Does it actually download the source? The actual php file? You never mentioned it. You said it asks to download it, but what are the contents of the downloaded file if you accept the download of it.
[QUOTE=PvtCupcakes;20215569]
What? How?[/QUOTE]
Make the script save the headers from the request, use a development proxy for logging the headers, etc.
To show you the differences between the requests the clients are making
[QUOTE=DrTaxi;20216836]Make the script save the headers from the request, use a development proxy for logging the headers, etc.
To show you the differences between the requests the clients are making[/QUOTE]
That's way over my head. :psyduck:
I'll see what I can do though.
[QUOTE=Nisd;20207915]Sound like you "hit" the wrong server? A probaly setup server would never output the source code.
Do you use DNS or ip to connect?[/QUOTE]
geh
I have this randomly with MediaWiki and Firefox. When you click on a link to a php page, it downloads the php file, but instead of php source there's a load of header bullshit in it.
Please tell us if the downloaded php file contains the source code or not.
If it does, you server is set up wrong and php is not working properly.
If it is just random shit, your header are probably messed up.
[QUOTE=bios_hazard;20227931]Please tell us if the downloaded php file contains the source code or not.
If it does, you server is set up wrong and php is not working properly.
If it is just random shit, your header are probably messed up.[/QUOTE]
I'm pretty sure it was the source code, but I'll have to check when I get to work today.
Okay, just got to work.
The only file having this problem is my login.php. And it does indeed download the source code.
If I go to account.php, that script actually does get executed and redirects me to back to login.php because I'm not logged in, and then I'm asked to download login.php.
If I go to one of my controller or model scripts that don't redirect it just shows a blank page. But it doesn't ask me to download anything.
This is login.php:
[php]
<?php
session_start();
if(isset($_SESSION["logged_in"])) {
header("Location: account.php");
}
?>
//HTML crap from here on
[/php]
I have a script called permissions.php that does the redirects.
account.php uses this to redirect back to the login page if the user isn't logged in. This does get executed because when I go to account.php I'm asked to download login.php.
account.php
[php]
<?php
session_start();
include("model/database.php");
include_once("controller/permissions.php");
redirect_non_user();
?>
[/php]
permissions.php
[php]
<?php
function logged_in() {
if(isset($_SESSION["logged_in"])) {
return true;
}
else {
return false;
}
}
//If non logged in user, take to login page
function redirect_non_user() {
if(!logged_in()) {
header("location:login.php");
}
}
//More stuff
?>
[/php]
[editline]11:36AM[/editline]
But like I said in the OP, this works fine in other browsers on this same computer. And it works on all other computers I've tested.
[editline]11:42AM[/editline]
What the hell, it works now.
As I was typing that last post, it wasn't working. Now it does and I didn't change anything. :bang:
xD
Well it is quite possible that it wasn't working before and the problem was cached.
Glad the problem fixed itself, but if you ever have a problem with anything PHP make sure you clear cache and hit Ctrl+F5 to do a full refresh.
Have to say though, I started freakin out when you stated that one php ran and the other downloaded.
I don't believe errors just disappear, but rather then hide themselves ready to strike when it's least appropriate. :D
This is an issue with the server, not the client. The server should process all .php files and send the output. There is no way that a client can download the source code if the server is doing it's job.
I'd check your Apache config files, any appropriate .htaccess files and the Apache access and error logs.
Sorry, you need to Log In to post a reply to this thread.