Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP options in firefox 1

Status
Not open for further replies.

Mthales

Technical User
Feb 27, 2004
1,181
GB
I am having a really weird problem with a php script page.
If I view the html page that has this php embedded in it from IE it is displayed as expected. But when I view it in firefox then the php block at the top of the file seems to be interpreted wrong. The result is that most of the code appears on the html page as one long string. Adding to my confusion is the fact that if my colleague views the page from his PC under IE or firefox then it is displayed as expected. (We both have v1.5 of firefox running on windows 2000.)

When I view the source under firefox then the first bit of the php block is shown in pink (as I'd expect) but the rest of the block is in black. Like this:
Code:
[COLOR=pink]<?php
	 include "common.php";
	 if(isset($_POST['LogOff'])){ clearOutCookies();}
	 $cookietxt = "<td>[/color]";
	if(isset($_COOKIE["logon"])){ $cookietxt .= $_COOKIE["logon"];}
	$cookietxt.= "</td><td>"; 
	
	if(isset($_COOKIE["address"])){
		 $cookietxt .= $_COOKIE["address"];
		 $ThisAddress = $_COOKIE["address"]; 
[code]

Does anyone know if there are settings in firefox somewhere that could be causing this?

M

[b]Trainee Chocolate Management Executive.[/b]
 
You're not seeing the PHP source code when you open the page in a browser and to "View source", are you? If so, you have a misconfiguration on your web server, as you should never see the actual code, only the output of the script.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I'm sorry I don't have an answer for you, but I thought you might like to know that I've been having the same problem running Firefox 1.0.7 on WinXP. The code does show up in the "Show Source". It doesn't seem to happen all the time, as most of my files work fine, and so I haven't done too much testing to see the source of the error, but I think that the culprit may be my editor... I've been using PHP Designer 2006 and it sometimes defaults to writing the document in Unicode. If I save the file in that format php won't interpret it. Worse, if I then resave the file out of unicode it comes up as garbage!

I don't know if this is the same problem you're having, but you may want to check the editor you're using and what character set it's using...
 
Thanks for your responses guys.

sleipnir214 - yes I am seeing the php code block in the "view page source" windows. As you say this is wrong! So I guess my browser is not recognising that it has to run the php script but it's just viewing it as text it doesn't understand.

arcyte - I'd not thought of that and I have edited the file in several different ways. So I checked this and found that it's currently encoded as ANSI and behaving the same.

M

Trainee Chocolate Management Executive.
 
It is not the browser which determines if the file needs to be parsed by PHP; it is the web server. PHP then sends the source to the browser. The browser knows nothing about PHP. Which is why sleipnir said:
sleipnir said:
you have a misconfiguration on your web server
 
oooo thanks for clarifying that for me - I'd kinda forgotten that posibility because IE could see it ok. I've got an Apache server so I'll check through the configuration files and see if I can spot anything.
M

Trainee Chocolate Management Executive.
 
I've looked at my Apache server configuration file but can't spot anything. Could you guys please review the php section for me?
httpd.conf said:
# Php stuff

ScriptAlias /php/ "c:/php/"

# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# For PHP 5
LoadModule php5_module "c:/php/php5apache.dll"

# specify the directory where php.ini is
SetEnv PHPRC C:/php
M

Trainee Chocolate Management Executive.
 
I don't know what all the other lines are for, but my PHP 5/Apache2 installation only includes:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# For PHP 5
LoadModule php5_module "c:/php/php5apache.dll"

In fact, the line:

Action application/x-httpd-php "/php/php-cgi.exe"

works at cross-purposes to the ones I've quoted above.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
But the reason, I believe, that you see nothing in IE is not that the script runs correctly when called by IE, but rather that IE interprets something inside "<?" and ?>" as a comment and hides it.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Sounds like the page might be running locally and not through the server. What's the URL in the browser when you run the PHP page? If it doesn't start with http://, it's most likely not running through the Apache server.

Lee
 
trollacious - I do believe you have cracked it! I was trying to view it in the browser from a "file:" location not through the "http:". When I change that the page works as I expect it to.
Thank all you very much for your help.
M

Trainee Chocolate Management Executive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top