Tigers Posted March 2, 2015 Share Posted March 2, 2015 <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 ) 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? Quote Link to comment https://forums.phpfreaks.com/topic/295014-running-php-in-html/ Share on other sites More sharing options...
ginerjm Posted March 2, 2015 Share Posted March 2, 2015 what is the name of this file? Quote Link to comment https://forums.phpfreaks.com/topic/295014-running-php-in-html/#findComment-1507223 Share on other sites More sharing options...
CroNiX Posted March 2, 2015 Share Posted March 2, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/295014-running-php-in-html/#findComment-1507227 Share on other sites More sharing options...
QuickOldCar Posted March 2, 2015 Share Posted March 2, 2015 The server may not configured properly to include htm or html files Contact your host and inform them of this, nginx handling htm and html files and not directly to apache? Quote Link to comment https://forums.phpfreaks.com/topic/295014-running-php-in-html/#findComment-1507230 Share on other sites More sharing options...
Tigers Posted March 7, 2015 Author Share Posted March 7, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/295014-running-php-in-html/#findComment-1507833 Share on other sites More sharing options...
boompa Posted March 7, 2015 Share Posted March 7, 2015 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"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/295014-running-php-in-html/#findComment-1507834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.