drums Posted November 24, 2010 Share Posted November 24, 2010 What would the code be to display server side code like the date and time to display in html pages? I have the date code for copyrights that I want to display <?php echo date(Y); ?> and I think I need to create an .htaccess file to put it in but not sure what to put. Thanks, Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted November 24, 2010 Share Posted November 24, 2010 If you want to send the server's date in an html page, it has to happen as you create the html on the server. You can't instruct the client to do this with an html tag. Quote Link to comment Share on other sites More sharing options...
drums Posted November 24, 2010 Author Share Posted November 24, 2010 That's the html tag <?php echo date(Y); ?> that I used so not sure what you mean. Shouldn't there be something to tell it to pars php? Examples of sites on same server (the 2nd link copyright is next to Veitch Law and not the SEO one and all the other pages on that site are hard coded) http://do-rightweb.com http://waduidefense.com/links.html Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted November 24, 2010 Share Posted November 24, 2010 Ah, you're wanting to force the html page to parse as php? You can do this in .htaccess, yes, add this line: AddType application/x-httpd-php .html If that doesn't work, here's a handful of other methods: http://www.velvetblues.com/web-development-blog/how-to-parse-html-files-as-php/ This will make the server treat any file with the .html extension as if it had the .php extension. Quote Link to comment Share on other sites More sharing options...
drums Posted November 24, 2010 Author Share Posted November 24, 2010 Sorry for my lack of the vernacular but this is exactly what I need. However, I put it in and it still doesn't show the date http://waduidefense.com/links.html Thanks, -jt. Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted November 24, 2010 Share Posted November 24, 2010 If you look at the source code you'll see that it's printing "Copyright © <?php echo date("Y"); ?> - The Veitch Law Firm – All Rights Reserved" - which means that the page is not being parsed as PHP. Either the functionality is disabled on your server, or you might need to try one of the other methods on that link I sent. Quote Link to comment Share on other sites More sharing options...
drums Posted November 24, 2010 Author Share Posted November 24, 2010 Thanks Jon, I will go through that link. Appreciate it! Quote Link to comment Share on other sites More sharing options...
tvmcgee Posted January 29, 2011 Share Posted January 29, 2011 I have tried the htaccess lines in the suggested link (good information). But I still can't get the PHP tags to work in HTML. I am using GoDaddy Deluxe with Linux Grid & PHP5. (I think this is new and different from the godaddy example in the referenced link). I think the Deluxe Grid uses the "cgi" part and the php5 is a little different than the other php. If I leave the cgi off .php files still work If I leave the "5" off the php the .php files still work If I add any AddType then the .html files don't work See the following test pages: http://hexpanse.com/dev/phpworking.php (works) http://hexpanse.com/dev/phpworking.html (not working) http://hexpanse.com/dev/layoutwithphp001.php (php gives syntax error on <?MLS version tag) I am using the following .htaccess file: AddType image/svg+xml .svg .svgz AddEncoding x-gzip .svgz AddHandler x-httpd-php5-cgi .php AddHandler x-httpd-php-cgi .php4 I got the last two php lines from this GoDaddy support page: http://community.godaddy.com/help/article/1082 I believe that I should be using php tags inside of .html files, and not the other way around. - Go Daddy support says don't do customer support for help with running scripts, and referee me to the help/support pages. Some of the other support posts there are using different set ups. But here is one that is close: http://community.godaddy.com/groups/web-hosting/forum/topic/php-using-html-file-extension/#post-95463 Please advise - thanks you for any help! Troy McGee troy@troymcgee.com Quote Link to comment 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.