...

View Full Version : PHP code appears in HTML source in browser! help!



dforbu
03-24-2004, 03:00 PM
I am running apache 2.0.40 on redhat 9, with php 4.2.2. Stock setup.

The PHP works IF I don't mix any HTML into the code.

<?php phpinfo(); ?>

works perfectly, but

<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY>
<?php phpinfo(); ?>
</BODY>
</HTML>

or even

<HTML>
<?php phpinfo(); ?>
</HTML>

does not. If I mix html tags in, and view the page with the browser, I see the line

<?php phpinfo(); ?>

in the page source. Is there some setting in php.ini or apache httpd.conf? I have several web servers running the same apache/php configuration, and I've never seen this happen before. It's as if apache isn't recognizing the '<? php' tags..

As a workaround, we're using echo to output HTML tags, but I should be able to mix up PHP and HTML.

firepages
03-24-2004, 03:08 PM
you have to save your files as .php (or whatever apache is configured to parse) regardless of having HTML content or not , eg if you save them as .html you will get your described issues.

dforbu
03-24-2004, 04:25 PM
Originally posted by firepages
you have to save your files as .php (or whatever apache is configured to parse) regardless of having HTML content or not , eg if you save them as .html you will get your described issues.

The pages are *.php, not *.html.

In my httpd.conf file there is:

AddHandler server-parsed .html .php
XBitHack On

files are chmod'ed world readable and executable.

Spookster
03-24-2004, 05:35 PM
You are probably getting crazy code outputted because the phpinfo() function already outputs all the basic HTML tags like <html> and <body>, etc. That is why is works just fine when you only have that one line in the file like so

<?php phpinfo(); ?>

DsgnrsTLZAdmin
03-24-2004, 07:04 PM
You might be saving them as .php however, some text editors don't reconize this and save it differently. Try saving it with quotes around the name. Example: "test.php" this will remove the quotes and save it as just test.php. It's worth the try..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum