Holiday image php script doesnt work!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Holiday image php script doesnt work!!

Post by cap2cap10 »

Greetings php technorati! Again, I humbly ask for your guidance on a matter of great importance. I am trying to create a php script that will switch and image when new month starts. Here is my code:

Code: Select all

<?php
$b = Date("l F d, Y");
$month = date("F",$b);
 
if ($month =! "October")
{
echo "<img src=images/logo.jpg width=323 height=121 >";
}
elseif ($month =! "November")
{
echo "<img src=images/logo.jpg width=323 height=121 >";
}
elseif ($month =! "December")
{
echo "<img src=images/logo.jpg width=323 height=121 >";
}
elseif ($month == "October")
{
echo "<img src=images/halloween_logo.jpg width=323 height=121 >";
}
elseif ($month == "November")
{
echo "<img src=images/Thanksgiving_logo.jpg width=323 height=121 >";
}
elseif ($month == "December")
{
echo "<img src=images/christmas_logo.jpg width=323 height=121 >";
}
?>
:banghead:

Here is the error:

Warning: date() expects parameter 2 to be long, string given in *****on line3

Can someone enlighten me?
Thanks in advance!

Batoe
Last edited by Benjamin on Fri May 29, 2009 10:16 am, edited 1 time in total.
Reason: Changed code type from text to php.
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Holiday image php script doesnt work!!

Post by JKM »

Try this:

Code: Select all

$b = Date("l F d, Y");
$month = date("F");
mischievous
Forum Commoner
Posts: 71
Joined: Sun Apr 19, 2009 8:59 pm

Re: Holiday image php script doesnt work!!

Post by mischievous »

Greetings! haha... ok sooo... I would do it this way... little more efficient IMO.

Code: Select all

 
<?php
$b = Date("l F d, Y");
$month = date("F");
switch($month)
{
    case "October":
        echo "<img src='images/halloween_logo.jpg' width='323' height='121' />";
        break;
    case "November":
        echo "<img src='images/Thanksgiving_logo.jpg' width='323' height='121' />";
        break;
    case "December":
        echo "<img src='images/christmas_logo.jpg' width='323' height='121' />";
        break;
    default:
        echo "<img src='images/logo.jpg' width='323' height='121' />";
}
?>
 :mrgreen: 
 
Post Reply