Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Loading diffentet page each day

    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

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    <?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

  • #3
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    <?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.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    post exactly what you did.

  • #5
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    $day=date(z);// day of the year 0-365
    This needs to be quoted.

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

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    aedrin ....

    works fine for me without the quotes.

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #9
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    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.

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    An interesting topic ...

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

  • #11
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •