Jump to content

Running PHP in HTML


Tigers

Recommended Posts

<html>
<head>
	<title>Footer.php</title>
</head>

<body>
ccfcgfcfccdx
<?php include 'footer-1.php'; ?>

</body>
</html>
<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

$filename = 'appliqueApr14.htm';
echo "Footer.php";
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?> 
<html>
<head>	
<title>Footer.php</title>
</head>
<body>ccfcgfcfccdx
<?php// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.
$filename = 'appliqueApr14.htm';
echo "Footer.php";if (file_exists($filename)) 
{    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));}
?> 
</body>
</html>

(I can't believe I am asking this question :confused: )

 

After a long break I am rewriting some HTML on my wife's site in Php to make updates easier, improve functionality etc.

 

I tried to add some inline PHP to refresh my memory (see above).

It wouldn't work'.

The output ccfcgfcccdx was seen but the PHP was ignored.

I checked that the file appliqueApr14.htm'' was in the same directory as the code.

 

I rewrote the code to have this snippet as an include portion. See 2nd snippet

They are linked together as the 3rd snippet.

 

The silly thing is that on the site the nav buttons on the left run as PHP with no apparent trouble.

 

The URL is http://www.petalsandpatches.com/footer.php

 

I can only assume that I am missing something so basic.

 

What have I done or not?

Link to comment
Share on other sites

By default, php only gets executed/parsed in .php files, not .html files. If you want it to parse .html (or .htm) files you'd have to setup your webserver up to do that. But there is not advantage, seo or otherwise, to have .html over .php. Best to just stick to .php

Link to comment
Share on other sites

Et al

Being looking further at this and am still confused.

Page on wife's site http://www.petalsandpatches.com/pincushions.php uses PHP to display the naviagtion bar on the left.

I have stripped out most of that code but leaving the navigation PHP in pace to compare.

The new page is http://www.petalsandpatches.com/footer-2.php. The output is the centre but just all just the php is echoed, nothing is done with it. All I want to do is echo the date to at least get me started. The footer-2.php has all the header information of pincushions.php to eliminate all variation causing trouble

Why does this not work

 

Footer-1.php

 

// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.
echo date("Y/m/d");
 
//$filename = 'appliqueApr14.htm';
//echo "Footer.php";
//if (file_exists($filename)) {
//    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
//}

?

Yet the more complex 

 

Navigation.php

 

<ul id="navbuttons">

<li><a href="index.php"><img src="buttons/crystal buttons/JoomlaButtonhome.png" alt="Petals & Patches home"></a></li>
<li><a href="pincushions.php"><img src="buttons/crystal buttons/JoomlaButtonpincushions.png" alt="Petals & Patches pincushion patterns"></a></li>
<li><a href="clothdolls.php"><img src="buttons/crystal buttons/JoomlaButtonclothdolls.png" alt="Petals & Patches cloth dolls patterns"></a></li>
<li><a href="stitcheries.php"><img src="buttons/crystal buttons/JoomlaButtonstitcheries.png" alt="Petals & Patches stitcheries patterns"></a></li>
<li><a href="applique.php"><img src="buttons/crystal buttons/JoomlaButtonapplique.png" alt="Petals & Patches applique patterns"></a></li>
<li><a href="bears.php"><img src="buttons/crystal buttons/JoomlaButtonbears.png" alt="Petals & Patches bear patterns"></a></li>
<li><a href="quilts.php"><img src="buttons/crystal buttons/JoomlaButtonquilts.png" alt="Petals & Patches bear patterns"></a></li>
<li><a href="bags.php"><img src="buttons/crystal buttons/JoomlaButtonbags.png" alt="Petals & Patches bag patterns"></a></li>
<li><a href="chalkboards.php"><img src="buttons/crystal buttons/JoomlaButtonchalkboards.png" alt="Petals & Patches chalkboard patterns"></a></li>
<li><a href="seasidemoments.php"><img src="buttons/crystal buttons/JoomlaButtonseasidemoments.png" alt="Petals & Patches Seaside Moments patterns"></a></li>
<li><a href="blockofthemonth.php"><img src="buttons/crystal buttons/JoomlaButtonbom.png" alt="Petals & Patches BoM patterns"></a></li>
<li><a href="accessories.php"><img src="buttons/crystal buttons/JoomlaButtonaccessories.png" alt="Petals & Patches accessories"></a></li>
<li><a href="ordering.php"><img src="buttons/crystal buttons/JoomlaButtonordering.png" alt="Petals & Patches bear ordering information"></a></li>
<li><a href="contactus.php"><img src="buttons/crystal buttons/JoomlaButtoncontact.png" alt="Contact Petals & Patches"></a></li>
<li><a href="stockists.php"><img src="buttons/crystal buttons/JoomlaButtonstockists.png" alt="Petals & Patches pattern stockists"></a></li>
<li><a href="mailto:info@petalsandpatches.com?subject=E-mail request for Petals and Patches"><img src="buttons/crystal buttons/JoomlaButtonemail.png" alt="E-mail Petals & Patches"></a></li>
<li><a href="links.php"><img src="buttons/crystal buttons/JoomlaButtonlinks.png" alt="Petals & Patches pattern stockists"></a></li>
<li><a href="http://ww8.aitsafe.com/cf/review.cfm?userid=A736163"><img src="buttons/crystal buttons/JoomlaButtonreviewcart.png" alt="Petals & Patches review cart"></a></li>
<li><a href="http://petalsandpatches.wordpress.com/"><img src="buttons/crystal buttons/JoomlaButtonblog.png" alt="Petals & Patches blog"></a></li>
</ul>

work?

The calling code is 

<?php include 'navigation.php'; ?>

<? include ("footer-1.php"); ?>

I have used the '' vs. "" within the includes to see what does or does not work.

 

What am I doing wrong

Link to comment
Share on other sites

The "complex" page has no PHP code in it at all; it is strictly HTML.

 

Problem with this:

 

<?php include 'navigation.php'; ?>

<? include ("footer-1.php"); ?>

 

is likely the use of short tags. Try this instead:

 

<?php include 'navigation.php'; ?>

<?php include ("footer-1.php"); ?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.