SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Perth W.A.
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trouble with code

    I keep getting a parse error with the following code.
    Can anyone help please?

    Colin

    <html>
    <head>
    <title>Background Colors change based on the day of the week</title>
    </head>
    <?php*
    $today*=*date("w");
    $bgcolor*=*array(
    "#FEF0C5",*"#FFFFFF",*"#FBFFC4",*"#FFE0DD",
    "#E6EDFF",*"#E9FFE6",*"#F0F4F1"
    );
    ?>
    <body bgcolor="<?php echo $bgcolor[$today]; ?>

    <br>This just changes the color of the screen based on the day of the week
    </body>
    </html>

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remove all the *'s and fix your editor
    And add a " to <body bgcolor="<?php echo $bgcolor[$today]; ?>

    <body bgcolor="<?php echo $bgcolor[$today]; ?>"

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    I think you also have to do a slight change in your array. I think date('w') willr return a number between 1 and 7. The index in an array starts on 0. So try
    PHP Code:
    $bgcolor = array(1=>'#FEF0C5''#FFFFFF''#FBFFC4''#FFE0DD''#E6EDFF''#E9FFE6''#F0F4F1'); 
    -Helge

  4. #4
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, well spotted.
    PHP Code:
    $today date('w')-1
    is another possible solution.


Bookmarks

Posting Permissions

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