php code not executing

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
anotherphpnoob
Forum Newbie
Posts: 8
Joined: Tue Aug 03, 2010 12:13 pm

php code not executing

Post by anotherphpnoob »

I am trying to use some php code inside of an html document and it does not work. I have a script.php file that executes perfectly when I try and use it. Here is the code I am currently using:

Code: Select all

<?php
 echo "<title>";
 echo "the Homepage!";
 echo "</title>";
?>
Any suggestions would be great.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: php code not executing

Post by AbraCadaver »

If the file doesn't have a .php extension then most webservers will not parse it for PHP. You can configure this, but it is normally not done by default.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
anotherphpnoob
Forum Newbie
Posts: 8
Joined: Tue Aug 03, 2010 12:13 pm

Re: php code not executing

Post by anotherphpnoob »

any good links on how i can do this?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: php code not executing

Post by AbraCadaver »

Windows: right click file, select rename, delete the html or htm and type php
Linux: mv file.html file.php
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
anotherphpnoob
Forum Newbie
Posts: 8
Joined: Tue Aug 03, 2010 12:13 pm

Re: php code not executing

Post by anotherphpnoob »

this is from another forum but its what i needed to know.
As for "rewriting" the page in PHP, that isn't necessary. In a PHP document, any HTML outside of the opening and closing PHP tags will get sent as normal, only PHP inside those tags will be executed.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: php code not executing

Post by AbraCadaver »

anotherphpnoob wrote:this is from another forum but its what i needed to know.
As for "rewriting" the page in PHP, that isn't necessary. In a PHP document, any HTML outside of the opening and closing PHP tags will get sent as normal, only PHP inside those tags will be executed.
Yep, and they had the same name and avatar as me :)
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
anotherphpnoob
Forum Newbie
Posts: 8
Joined: Tue Aug 03, 2010 12:13 pm

Re: php code not executing

Post by anotherphpnoob »

lol, same here obviously.
Post Reply