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
Pezmc
Forum Commoner
Posts: 53 Joined: Mon Nov 06, 2006 2:15 pm
Post
by Pezmc » Mon Nov 06, 2006 2:17 pm
I have written this script (Is hosted at
http://www.shogans.com/sig/countdown2.php
However for some reason it allways counts to the thirtyith of the month. Can any one find the bug.
Code: Select all
<?
// Settings
$month = 12;
$day = 08;
$year = 2006;
$target = mktime(0,0,0,$month,$day,$year);
$diff = $target - time();
// Found in google
$days = ($diff - ($diff % 86400)) / 86400;
$diff = $diff - ($days * 86400);
$hours = ($diff - ($diff % 3600)) / 3600;
$diff = $diff - ($hours * 3600);
$minutes = ($diff - ($diff % 60)) / 60;
$diff = $diff - ($minutes * 60);
$seconds = ($diff - ($diff % 1)) / 1;
//Png Stuff
header ("Content-type: image/png");
$imgname = "nintendowii.png";
//Image Creation
$img = @imagecreatefrompng ($imgname);
$white = imagecolorallocate ($img, 255, 255, 255);
//Text
imagestring ($img, 3, 210, 18, "$days day(s) $hours hour(s)", $white);
imagepng ($img);
imagedestroy ($img);
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Nov 06, 2006 2:48 pm
hint: echo $day.
Pezmc
Forum Commoner
Posts: 53 Joined: Mon Nov 06, 2006 2:15 pm
Post
by Pezmc » Mon Nov 06, 2006 4:07 pm
Thanks so it has to be in brackets. Why does it have to be in brackets (So i remember next time)
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Mon Nov 06, 2006 4:27 pm
Pezmc wrote: Thanks so it has to be in brackets. Why does it have to be in brackets (So i remember next time)
08 is invalid
octal number
jimthunderbird
Forum Contributor
Posts: 147 Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA
Post
by jimthunderbird » Tue Nov 07, 2006 2:31 am
change $day = 08 to $day=8 it will work