Page 1 of 1
timing out
Posted: Wed Oct 09, 2002 2:04 pm
by matthiasone
ok, when I goto a certain page I get either a blank page that never loads or a time out error. that script as worked before. I call the same function called on this on the previous page. Any ideas what the problem might be?
When I do the get the error it give me a line number which points to an if statement.
Matt
Posted: Wed Oct 09, 2002 4:10 pm
by Coco
show us the code?
sounds like your if statement either falls over or goes into an infinate loop, timing out when the server tells it to sod off
Posted: Wed Oct 09, 2002 4:19 pm
by matthiasone
the calling function:
Code: Select all
$mth = $partsї1] - 2;
$tyear = $partsї0];
for($i = 1; $i <= 12; $i++)
{
$mth += 1;
$monthsї$i] = make_yrtomth($tyear, $mth, $user, "e");
if ($mth == 12)
{
$tyear = $tyear + 1;
$mth = 0;
}
}
the function called (bold where the error is said to be):
Code: Select all
function make_yrtomth($cyear, $mth, $mode)
{
$first_of_mth = strtotime($mth."/1/".$cyear);
$day_one = getdate($first_of_mth);
if ($day_oneї"mon"] == 1)
$max_days = 31;
elseif ($day_oneї"mon"] == 2)
{
if(checkdate(2, 29, $day_oneї"year"]))
$max_days = 29;
else
$max_days = 28;
}
elseif ($day_oneї"mon"] == 3)
$max_days = 31;
elseif ($day_oneї"mon"] == 4)
$max_days = 30;
elseif ($day_oneї"mon"] == 5)
$max_days = 31;
elseif ($day_oneї"mon"] == 6)
$max_days = 30;
elseif ($day_oneї"mon"] == 7)
$max_days = 31;
elseif ($day_oneї"mon"] == 8)
$max_days = 31;
elseif ($day_oneї"mon"] == 9)
$max_days = 30;
elseif ($day_oneї"mon"] == 10)
$max_days = 31;
elseif ($day_oneї"mon"] == 11)
$max_days = 30;
elseif ($day_oneї"mon"] == 12)
$max_days = 31;
$week = 1;
$cnt = 1;
for ($i=0; $i <= 6; $i++)
{
if ($i >= $day_oneї"wday"] && $mode == "e")
{
$row1 .= "<td align='center'><font size='2'><a href='staffpage.php?area=form&page=cal&view=day&id=".
$day_oneї"year"]."-".$day_oneї"mon"]."-".$cnt."'>".$cnt."</a></font></td>\n";
$cnt += 1;
}
if ($i >= $day_oneї"wday"] && $mode == "v")
{
$row1 .= "<td align='center'><font size='2'><a href='staffpage.php?area=form&page=cal&view=week&id=".
$day_oneї"year"]."-".$day_oneї"mon"]."-".$cnt."'>".$cnt."</a></font></td>\n";
$cnt += 1;
}
elseif ($i < $day_oneї"wday"])
$row1 .= "<td> </td>\n";
}
while ($cnt <= $max_days)
{
echo"c=".$cnt." md=".$max_days."<BR>";
$week += 1;
$temp = "row".$week;
for ($k=0; $k <= 6; $k++)
{
їb]if ($cnt <= $max_days)ї/b]
{
if ($mode == "e")
{
$$temp .= "<td align='center'><font size='2'><a href='staffpage.php?area=form&page=cal&view=day&id=".
$day_oneї"year"]."-".$day_oneї"mon"]."-".$cnt."'>".$cnt."</a></font></td>\n";
$cnt += 1;
}
elseif ($mode == "v")
{
$$temp .= "<td align='center'><font size='2'><a href='staffpage.php?area=form&page=cal&view=week&id=".
$day_oneї"year"]."-".$day_oneї"mon"]."-".$cnt."'>".$cnt."</a></font></td>\n";
$cnt += 1;
}
}
else
$$temp .= "<td> </td>\n";
}
}
for ($j=1; $j <= $week; $j++)
{
$temp = "row".$j;
$body .= "<tr>".$$temp."</tr>\n";
}
$month ="<table border='0' cellpadding='3' cellspacing='0'>\n<tr>".
"<td colspan='7' align='center'><font size='2'><b>".$day_oneї"month"].
"</b></font></td>\n</tr>\n<tr align='center'>\n<td bgcolor='#256AA3'><font size='2' color='white'>S</font></td>\n".
"<td bgcolor='#256AA3'><font size='2' color='white'>M</font></td>\n<td bgcolor='#256AA3'><font size='2' color='white'>T</font></td>\n".
"<td bgcolor='#256AA3'><font size='2' color='white'>W</font></td>\n<td bgcolor='#256AA3'><font size='2' color='white'>T</font></td>\n".
"<td bgcolor='#256AA3'><font size='2' color='white'>F</font></td>\n<td bgcolor='#256AA3'><font size='2' color='white'>S</font></td>\n</tr>".
$body."</table>";
return $month;
}
Posted: Wed Oct 09, 2002 4:22 pm
by matthiasone
ignore the I was trying to bold that line of code. those aren't in the code.
Matt
Posted: Wed Oct 09, 2002 4:31 pm
by Coco
}
else
$$temp .= "<td> </td>\n";
abuot 10 lines below the 'faulty' if statement... try taking a $ off and see what happens
[edit]
Also spotted it several times thru the if statement itself............
[/edit]
Posted: Wed Oct 09, 2002 6:32 pm
by hob_goblin
Coco wrote:}
else
$$temp .= "<td> </td>\n";
abuot 10 lines below the 'faulty' if statement... try taking a $ off and see what happens
[edit]
Also spotted it several times thru the if statement itself............
[/edit]
that shouldn't do it. variable variables.
Code: Select all
$a = "b";
$b = "c";
echo $$a; //should print "c"
Posted: Wed Oct 09, 2002 9:40 pm
by zebrax
Ty passing the right number of variables into the function.
Code: Select all
$monthsї$i] = make_yrtomth($tyear, $mth, $user, "e");
4 options
function only wants 3
Code: Select all
function make_yrtomth($cyear, $mth, $mode)
Posted: Fri Oct 11, 2002 12:26 pm
by matthiasone
Well, zebrax I never got notification about your post, but I figured it out on my own..........but your were correct...
Matt