PHP error?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mogman42
Forum Newbie
Posts: 18
Joined: Fri May 21, 2004 10:00 am

PHP error?

Post 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!
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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?
mogman42
Forum Newbie
Posts: 18
Joined: Fri May 21, 2004 10:00 am

Post 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.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

ummm.... and if you change it to .php but leave the HTML tags in?
mogman42
Forum Newbie
Posts: 18
Joined: Fri May 21, 2004 10:00 am

Post 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?
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

only if you have configured your server to do that.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

mogman - you can, if you configure Apache to parse .html files as PHP as well.
mogman42
Forum Newbie
Posts: 18
Joined: Fri May 21, 2004 10:00 am

Post 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


????
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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 ;)
mogman42
Forum Newbie
Posts: 18
Joined: Fri May 21, 2004 10:00 am

Post 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
Post Reply