My embedded php code won't execute

Reply

Join Date: Aug 2004
Posts: 29
Reputation: techhelpforme is an unknown quantity at this point 
Solved Threads: 0
techhelpforme's Avatar
techhelpforme techhelpforme is offline Offline
Light Poster

My embedded php code won't execute

 
0
  #1
Oct 10th, 2004
This works:

-----------PrintInfo.php
<?php
phpinfo();
?>
--------------------------

But this doesn't:

-------------PrintInfo.html
<html>
<head>
<title> Hello World </title>
</head>
<body>
<?php

echo 'This is my first PHP web page.';

?>
</body>
</html>
-------------------------

I'm using Apache 2.0 on WinXP Home with php 5.

Thanks!
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 282
Reputation: Roberdin will become famous soon enough Roberdin will become famous soon enough 
Solved Threads: 6
Team Colleague
Roberdin Roberdin is offline Offline
Supreme Evil Overlord

Re: My embedded php code won't execute

 
0
  #2
Oct 10th, 2004
It has to end in .php to be parsed by the PHP engine, change your file name back to PrintInfo.php.

The HTML code (within the PrintInfo.php code) will not be analysed by the PHP parser, bnut instead be sent straight to output. The PHP parser only reads between the <?php and ?> tags.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 29
Reputation: techhelpforme is an unknown quantity at this point 
Solved Threads: 0
techhelpforme's Avatar
techhelpforme techhelpforme is offline Offline
Light Poster

Re: My embedded php code won't execute

 
0
  #3
Oct 10th, 2004
Originally Posted by Roberdin
It has to end in .php to be parsed by the PHP engine, change your file name back to PrintInfo.php.

The HTML code (within the PrintInfo.php code) will not be analysed by the PHP parser, bnut instead be sent straight to output. The PHP parser only reads between the <?php and ?> tags.
Thanks Roberdin. Sorry I should have specified that I'm trying to make web pages with embedded php work, so I was wanting .html files to work. I found out I needed to add this line to my httpd.conf file in the Apache directory:
AddType application/x-httpd-php .html
to get apache to associate .html files with the php engine.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 234
Reputation: PoA is an unknown quantity at this point 
Solved Threads: 8
PoA PoA is offline Offline
Posting Whiz in Training

Re: My embedded php code won't execute

 
0
  #4
Oct 10th, 2004
Another way round to use .html is use mod_rewrite to convert .php to .html (any file format you can convert)
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 49
Reputation: felgall is an unknown quantity at this point 
Solved Threads: 1
felgall felgall is offline Offline
Light Poster

Re: My embedded php code won't execute

 
0
  #5
Oct 11th, 2004
The command to add to .htaccess to get html files treated as php is:

AddHandler server-parsed .html
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC