Click to See Complete Forum and Search --> : [RESOLVED] Script crashing server


AmazingAnt
11-02-2006, 04:53 PM
Ok, I have no clue why, but somehow this PHP page is crashing my server every time I try to access it through my browser.
Calander.txt is the main file, calevents.txt is the "calevents.php" that the main file refers to, and calevents2.txt is the csv file that the data is coming from.
Anyone want to suggest what I broke?

NogDog
11-02-2006, 10:58 PM
Before this loop in the main file, where does $eventtotal get set?

<?php
$cal_var_num_two = 1;
while ($cal_var_num_two != $eventtotal){
$neweventname = "event".$cal_var_num_two;
echo $$neweventname;
$cal_var_num_two = $cal_var_num_two + 1;
}

You might want to change the "!=" to a "<" comparison in order to prevent an infinite loop.

PS: In fact, it might be better to write it as:

for($cal_var_num_two = 1; $cal_var_num_two < $eventtotal; $cal_var_num_two++) {
$neweventname = "event".$cal_var_num_two;
echo $$neweventname;
}

AmazingAnt
11-03-2006, 06:10 AM
In the included file. But thanks for making me take a look. I was setting $eventtotal to a string, and using it as an integer.
Your for loop works very well, so thanks for that as well.