Can any one find the bug?

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
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Can any one find the bug?

Post 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);
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hint: echo $day.
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Post by Pezmc »

Thanks so it has to be in brackets. Why does it have to be in brackets (So i remember next time)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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
User avatar
jimthunderbird
Forum Contributor
Posts: 147
Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA

Post by jimthunderbird »

change $day = 08 to $day=8 it will work
Post Reply