Page 1 of 1

Holiday image php script doesnt work!!

Posted: Wed May 27, 2009 9:01 pm
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

Re: Holiday image php script doesnt work!!

Posted: Wed May 27, 2009 9:07 pm
by JKM
Try this:

Code: Select all

$b = Date("l F d, Y");
$month = date("F");

Re: Holiday image php script doesnt work!!

Posted: Thu May 28, 2009 12:51 am
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: