> I've got some strange problems whilst passing variables from forms into my
> php-script. When I use IE5 it works like a charm. Using Opera or IE4* the
> referred "action" script crashes due to memory restrictions on the server,
> in a function I use to get all the dates between two given dates,
presumably
> due to my while condition never turning false. This lead me to believe
that
> my variables were being gargled in some way as to make the parsing fail,
> this is however not the case as far as I can tell.

Are you printing out the data?...

> This is the function I use to retrieve all the dates inbetween $from and
$to
> inclusive (yes, it's butt ugly, I know, but I'm in kinda of a hurry, my
> deadline is approaching ;) :
>
> /*
>  Function geDates(from, to) takes strings containing dates in the form
> "YYYY-MM-DD"
>     and returns an array containing the dates between "from" and "to"
> inclusive
> */
>
> function getDates($from, $to) {
>  (int) $year=substr($from,0,4)+0; /* Adding the zero is a kluge  to force
> away leading zeros */
>  (int) $month=substr($from,5,2)+0;
>
>  (int) $day=substr($from,8,2)+0;
>
>  $datearray[0]=$from;
>  $current=$from;
>  while($current!=$to) {
>   $day=$day+1;
>   if(checkdate($month, $day, $year)) {
>    $current=zeroPadDate($year, $month, $day);
>    $datearray[]=$current;
>   } else {
>    $month=$month+1;
>    $day=1;
>    if (checkdate($month, $day, $year)) {
>     $current=zeroPadDate($year, $month, $day);
>     $datearray[]=$current;
>    } else {
>     $year=$year+1;
>     $month=1;
>     $current=zeroPadDate($year, $month, $day);
>     $datearray[]=$current;
>    }
>   }
>
>  }
>  return $datearray;
> }

Uhhh.  You're working *WAY* too hard :-)

function getDates($from, $to){
    # Change the 1's to 0's to turn off debugging output:
    if (1){
        echo "Computing Dates Between '$from' and '$to'<BR>\n";
    }
    $year = substr($from, 0, 4);
    $month = substr($from, 5, 2);
    $day = substr($from, 8, 2);
    $start = mktime(0, 0, 0, $month, $day, $year);
    $year = substr($to, 0, 4);
    $month = substr($to, 5, 2);
    $day = substr($to, 8, 2);
    $end = mktime(0, 0, 0, $month, $day, $year);
    # Change this to <= to get the $end date included:
    while ($start < $end){
        $datearray[] = date('Y-m-d', $start);
        if (1){
            echo $datearray[count($datearray)-1], "<BR>\n";
        }
        $day++;
        # Let PHP worry about wrapping days and months and leap years
        $start = mktime(0, 0, 0, $month, $day, $year);
    }
    return $datearray;
?>

> /* Accessory function to getDates above.  */
>
> function zeroPadDate($year, $month, $day) {
>  if ($month<10) $mstr="0$month";
>  if ($day<10) $dstr="0$day";
>  return "$year-$mstr-$dstr";
> }

You don't need this function. :-)

> What could it possibly be due to? Are there any differencies in the way
the
> above mentioned browsers pass the form variables?
>
> If you do find it in your heart to help me out with this one, please also
> reply by e-mail to [EMAIL PROTECTED]
>
> Thanks in advance,
>
> Claes Andersson
> Webmaster, www.palladiumbio.com
>
> PS Exchanging "GET" and "POST" in the referring form made no difference in
> the world DS
>
>
>


--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to