...

View Full Version : Loading diffentet page each day



stephan_pieri
03-19-2007, 01:41 PM
Hiya Guys.

I have done a quick search on your forum, but could not find a suitable answer.

What i want is a new page loading every day. So the index of my site will be index.php, and i want to tell the PHP page to load page1.php/htm if it is day 1, page2.php/htm if it is day 2 and so on.

These pages will be stored on the same server, but may be contained in their own directory.

I believe that some arithmacy is involved, and that i have to base the calculations on the time or date functions, however i have not used these before, so would appreciate any help in this area.

Cheers in advance for your help

mlseim
03-19-2007, 01:58 PM
<?php
$day=date(z);// day of the year 0-365
$page="page".$day.".php";
header ("location: $page");// redirect to the page.
?>


FYI: http://us3.php.net/date

stephan_pieri
03-19-2007, 02:07 PM
<?php
$day=date(z);// day of the year 0-365
$page="page".$day.".php";
header ("location: $page");// redirect to the page.
?>


FYI: http://us3.php.net/date

Thank you for helping. This is what i wanted, but initially i got an error about the header. I changed this to 'include()' statement and took out location. It all seems to work but from one thing. When i preview it on my server, " " seems to display before the contents of the requested page.

mlseim
03-19-2007, 02:13 PM
post exactly what you did.

stephan_pieri
03-19-2007, 02:14 PM
Sorry guys, i got it sorted out. It was totally my mistake.

It was the way i coded the extra pages, mixing up the DOCTYPE with PHP code. After removing the html stuff and just leaving the <?php---?>, it started to work.

I'd like to thank you once again for helping me with this, it is much appreciated.

Regards

aedrin
03-19-2007, 04:10 PM
$day=date(z);// day of the year 0-365

This needs to be quoted.



$day=date('z');// day of the year 0-365

mlseim
03-19-2007, 05:31 PM
aedrin ....

works fine for me without the quotes.

Nightfire
03-19-2007, 06:46 PM
Although it works fine, it should trigger a notice in the error logs as it's looking for a constant. If the constant isn't found, it then looks for the (can't think of the name) value of the date you're looking for

aedrin
03-19-2007, 07:55 PM
This is one of the current issues of PHP.

It is far too lenient in its syntax parsing.

I understand PHP is meant to be easy to use. But allowing syntax errors is just plain wrong.

I suppose they shot themselves in the foot by doing this. Because if they ever want to change it to an error, and not a notice, they'd break half the websites out there.

mlseim
03-19-2007, 08:02 PM
An interesting topic ...

I wonder how many other things like that we could find.

aedrin
03-19-2007, 10:34 PM
Just load a website, browse it. Then check the error logs.

There's quite a few PEAR modules out there that will spam your error logs. (MDB2 for example)

One of the reasons I don't use PEAR unless I can't find an alternative (self made or otherwise).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum