PDA

View Full Version : function problem



koolkrasher
November 18th, 2008, 05:30 PM
I have a function that checks the date and if the date matches the currentdate then its going to include a htm file if it doesnt then include the default htm file.
Seems to only wokr for the default.



function getCandle(){
$month = date(m);
$day = date(d);
$currentDate = $month.$day;
if(currentDate==1221)
{
include("1.htm");
}
else if(currentDate==1222)
{
include("2.htm");
}else if(currentDate==1223)
{
include("3.htm");
}else if(currentDate==1224)
{
include("4.htm");
}else if(currentDate==1225)
{
include("5.htm");
}else if(currentDate==1226)
{
include("6.htm");
}else if(currentDate==1227)
{
include("7.htm");
}else if(currentDate==1228)
{
include("8.htm");
}else
{
include("default.htm");
}
}


if it works off of the server clock wich in my case i guess would be localhost, current date shows todays date but the conditional doest reconize it.

any one have any ideas whats up with this?

mainegate
November 19th, 2008, 12:04 AM
In your if statements you didn't put a $ in front of your variables..so it should be $currentDate



I have a function that checks the date and if the date matches the currentdate then its going to include a htm file if it doesnt then include the default htm file.
Seems to only wokr for the default.



function getCandle(){
$month = date(m);
$day = date(d);
$currentDate = $month.$day;
if(currentDate==1221)
{
include("1.htm");
}
else if(currentDate==1222)
{
include("2.htm");
}else if(currentDate==1223)
{
include("3.htm");
}else if(currentDate==1224)
{
include("4.htm");
}else if(currentDate==1225)
{
include("5.htm");
}else if(currentDate==1226)
{
include("6.htm");
}else if(currentDate==1227)
{
include("7.htm");
}else if(currentDate==1228)
{
include("8.htm");
}else
{
include("default.htm");
}
}


if it works off of the server clock wich in my case i guess would be localhost, current date shows todays date but the conditional doest reconize it.

any one have any ideas whats up with this?

borrob
November 19th, 2008, 08:39 AM
also for this better use a switch:


function getCandle(){
$month = date(m);
$day = date(d);
$currentDate = $month.$day;
switch( $currentDate )
{
case 1221:
{
include("1.htm");
break;
}
case 1222:
{
include("2.htm");
break;
}
default:
{
include("default.htm");
break;
}
}

koolkrasher
November 20th, 2008, 12:22 AM
Hah cant belive i missed the $ thanks for pointing that out. Ill give the swich a shot also.

Thanks guys