<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Cycle Tracks Portal</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
	<?php
		$date = ('l dS \of F Y');
	?>
</head>

<body>
<div class="content">
	<div class="topmenu">
		<div class="date_">
		<?php
		echo $date;
		?>
	</div>
</div>

the php code in this html page doesn't work. pls help

Recommended Answers

All 17 Replies

line ten needs to be $date = date('l dS F Y');

you must to chane the variable date to


$date = date('l dS F Y');

<html>
<head>
	<title>Cycle Tracks Portal</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
	<?php
		$date_curr = date('l dS F Y');
	?>
	
</head>

<body>
<div class="content">
	<div class="topmenu">
		<div class="date_">
		<?php
		echo $date_curr;
		?>
	</div>
</div>

Still not working.

the \of is what is breaking it, it is not part of the date format

removing it also not working.

also use comma's between the params in the date function
$date_curr = date('l, dS, F, Y');

still not working.

also use comma's between the params in the date function
$date_curr = date('l, dS, F, Y');

you only have to use commas if you want commas to appear in the output

still not working.

what part is not working, Everything seems to work when I run it...what are you trying to do?

also, just to make sure we're not missing something obvious here...you are saving the page as .php extension right?

the main problem is that I trying to make the above code works in .html format. I know that when you save it as .php it works.

it wont work in the .html format as it needs the php engine to get it to work

Or, you have to make php parse the files with html extensions. Add AddType application/x-httpd-php .html to your httpd.conf file of apache. It will parse html files as php.

Cheers,
Naveen

Understand but don't know how to do, pls teach.

Are you running on a local system or on a server ?

local system

<html>
<head>
	<title>Cycle Tracks Portal</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
	<?php
		$date_curr = date('l dS F Y');
	?>
	
</head>

<body>
<div class="content">
	<div class="topmenu">
		<div class="date_">
		<?php
		echo $date_curr;
		?>
	</div>
</div>

Still not working.

Why don't you try it something like this:

<html>
<head>
	<title>Cycle Tracks Portal</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
</head>
</html>
<?php 	
    $date_curr = date('l dS F Y'); 
    // assign vars for template
    $template->assign_vars(array(
	'DATE'	=> $date_curr)
);
?>
<html>
<body>
<div class="content">
	<div class="topmenu">
                     
		<div class="date_">{DATE}</div>
</div>

That should get you to the basics of what you need. You might need to use phpBB's template.php file to use it like this. I've attached it for you. You'll have to change the file to work with your program. I use it every so often when I work on things like this.

Or, if you don't want to use the phpBB script, you can also do it like this:

<?php
echo('<html>
<head>
	<title>Cycle Tracks Portal</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
</head>');
$date_curr = date('l dS F Y');
echo('<body>
<div class="content">
	<div class="topmenu">
                     
		<div class="date_">');
echo($date_curr);
echo('</div>
</div>');

Hopefully that'll help you out also. You simply echo the HTML codes within the PHP file. That way you don't have to mess around with the template vars.

Open httpd.conf file in apache/conf and add the line (which I have posted above) in it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.