Page 1 of 1

PHP error?

Posted: Fri May 21, 2004 10:00 am
by mogman42
I've installed the following on a test server and its been running fine...

Apache 2.0.49
PHP 4.3.6
mySQL 4.0.18

My problem is this, I've edited/tweaked httpd.conf and php.ini according the install guides.

On the web server, I can run/display/load any .php file, however when I try to embed php code/scripts into an html file it fails to load and I just get a blank webpage.

Example...

Code: Select all

<html>
<body>
<?

print "This is a PHP test!";

?>
</body>
</html>
But if I make test.php with just the PHP code, it will load/display fine.

Any ideas? I am assuming there is something flawed with the apache or php config files, but I've tested/changed everything I can think of, double checked the AddType, LoadModule lines, etc....

Thanks in advance for any advice, comments, suggestions!

Posted: Fri May 21, 2004 10:04 am
by jason
Try:

Code: Select all

<html>
<body>
<?php

print "This is a PHP test!";

?>
</body>
</html>
And then view source if you don't see anything. Do you see the PHP code?

Posted: Fri May 21, 2004 10:13 am
by mogman42
Modified code to what you have above....

Still get a blank page...

View source gives me all the code html and php.......

I'm stumped....???

But if I change the file extension to .php and remove the HTML tags it will work fine.

Posted: Fri May 21, 2004 10:20 am
by Wayne
ummm.... and if you change it to .php but leave the HTML tags in?

Posted: Fri May 21, 2004 10:32 am
by mogman42
lol.........wish I had thought of that.....

just tried it and it works....thanks very much!

however, I thought you should be able to have PHP code inside an html document and it would still be read/parsed properly?

Posted: Fri May 21, 2004 10:42 am
by Wayne
only if you have configured your server to do that.

Posted: Fri May 21, 2004 11:38 am
by launchcode
mogman - you can, if you configure Apache to parse .html files as PHP as well.

Posted: Fri May 21, 2004 12:31 pm
by mogman42
I thought thats what these lines were for in httpd.conf ?

Addtype application/x-httpd-php .php .phtml
AddType text/html .php
AddType application/x-httpd-php-source .phps

AddHandler php-script php


????

Posted: Fri May 21, 2004 12:47 pm
by launchcode
Look at what the lines do - they define which file extensions will be parsed as PHP - so far .php and .phtml will be - have a guess how you add .html to that list ;)

Posted: Fri May 21, 2004 12:58 pm
by mogman42
Bingo....thanks very much...!!!! :D

Guess I just needed to slow down and pay attention to the details....didn't think about what each line actually did, just cross checked it against other config/setup options in the documentation.

Now for mySQL connectivity........but I'll slog thru that on my own :P