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
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Wed May 27, 2009 9:01 pm
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 >";
}
?>
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
Post
by JKM » Wed May 27, 2009 9:07 pm
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
Post
by mischievous » Thu May 28, 2009 12:51 am
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: