Page 1 of 1

Can any one find the bug?

Posted: Mon Nov 06, 2006 2:17 pm
by Pezmc
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);
?>

Posted: Mon Nov 06, 2006 2:48 pm
by feyd
hint: echo $day.

Posted: Mon Nov 06, 2006 4:07 pm
by Pezmc
Thanks so it has to be in brackets. Why does it have to be in brackets (So i remember next time)

Posted: Mon Nov 06, 2006 4:27 pm
by Weirdan
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

Posted: Tue Nov 07, 2006 2:31 am
by jimthunderbird
change $day = 08 to $day=8 it will work