php-windows Digest 7 Dec 2009 15:55:44 -0000 Issue 3732

Topics (messages 29746 through 29749):

=== Application Error 1000 ===
        29746 by: Láïa Èerník

Re: Static array causing problem in recursion
        29747 by: Midhun Girish
        29748 by: Richard Quadling

PHP Data Grid
        29749 by: Harpreet

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Operating system: Windows Server 2008 R2, SP1, 64bit

In the system are created 2 scheduled tasks.
 uloha_1 and uloha_2.
The role uloha_1 runs every 5 min.
The role uloha_2 runs every 5 min.
Tasks uloha_1 is run this command:
 C:\inetpub\wwwroot\wscctyrlistek\php\php-cgi.exe -f 
C:\inetpub\wwwroot\wscctyrlistek\app\ws.php
Tasks uloha_2 is run this command:
 C:\inetpub\wwwroot\wscctyrlistek\php\php-cgi.exe -f 
C:\inetpub\wwwroot\wscctyrlistek\app\ws2.php

Problem: Sometimes (intermittently happens) that the job runs as follows:
Level Date and Time Event ID Category role...
 Information 3.12.2009 12:12:56 102 task was completed. (2)...
 Information 3.12.2009 12:12:56 201 event was completed. (2)...
 Information 3.12.2009 12:12:49 129 process-based tasks ...
 Information 3.12.2009 12:12:49 100 Role of running (1) ...
 Information 3.12.2009 12:12:49 200 Action starts (1) ...
 Information 3.12.2009 12:12:49 319 Module tasks received a message asking 
to run the task ....
 Information 3.12.2009 12:12:49 107 event running scheduler ...
where the ID Event 201 arises System Error:
Log Name: Application
Source: Application Error
Date: 3.12.2009 10:36:10
Event ID: 1000
Category: (100)
Level: Error
Keywords: Classic
User: N / A
Computer: SRV03. ergo.local
Description:
 Faulting application php-cgi.exe, version 5.2.0.0,
 time stamp 0x4549cf1d,
 Faulting module kernel32.dll, version 6.0.6001.18000,
 time stamp 0x4791a783,
 fault address 0xc0000142, shift error 0x0006ecfb, process ID 0x3028,
 time start 0x01ca73fc0bc6c1e9.
Did anyone what to or where to find the cause.
Thank you. 



--- End Message ---
--- Begin Message ---
hello all,

hey Richard Quadling you are right... sorry man.. i just noticed that just
now.

Actually i missed th line self::getAllChildren($child,$levelcount,False);
that you gave and thought it was a mistake...that y i updated the
script...you can imagine the condition of a person who searched over 250
pages in internet for this.. :)....i haven't updated the pages yet.... thank
you for the heads up.. i will take it as you gave...


Midhun Girish



On Fri, Dec 4, 2009 at 5:48 PM, Richard Quadling
<rquadl...@googlemail.com>wrote:

> 2009/12/4 Midhun Girish <midhungir...@gmail.com>:
> > Hello ,
> >
> > Richard Quadling thank you so much.. your trick worked... :) now its
> > working.. heres the modified code...
> >
> >  public function getAllChildren($node,$level,$firstCall=false)
> >>
> >>   {
> >>       static $rootsarray=array();
> >>       static $levelcount;
> >>       if($firstCall) {
> >>           $rootsarray=array();
> >>       }
> >>       $levelcount=$level;
> >>       $child=self::getChild($node);
> >>       if($child==''||$levelcount==0)
> >>       {
> >>           return 1;
> >>       }
> >>       else
> >>       {
> >>           $levelcount--;
> >>           $rootsarray[]=$child;
> >>           self::getAllChildren($child,$levelcount,False);
> >>       }
> >>       return $rootsarray;
> >>
> >>   }
> >>
> >
> > and i call the function like :
> >
> >  $nodearray=tree::getAllChildren('W1',10,true);
> >
> >
> > Thank you so much for your support...
> >
> > Midhun Girish
> >
> >
> > On Fri, Dec 4, 2009 at 3:18 PM, Richard Quadling <
> rquadl...@googlemail.com>
> > wrote:
> >>
> >> 2009/12/4 Midhun Girish <midhungir...@gmail.com>
> >> >
> >> > Hello guys,
> >> > I was trying to use a recursive function to do a tree traversal.. i
> used
> >> > a
> >> > static array to store the nodes at each recursion.. The function works
> >> > correctly if it is called only once during an execution.. but when i
> >> > call it
> >> > twice or more, the nodes get appended to the array...hers the var dump
> >> > of
> >> > the array...
> >> > Three:Array ( [0] => W4 )
> >> > Two:Array ( [0] => W4 [1] => W3 [2] => W4 )
> >> > One:Array ( [0] => W4 [1] => W3 [2] => W4 [3] => W2 [4] => W3 [5] =>
> W4
> >> > )
> >> >
> >> > I tried to reset() the array and all but not working..i am not able to
> >> > chnage the index of the $rootsarray  back to 0... the new elelnts are
> >> > added
> >> > at the end only...can anyone give me a push in the right direction??
> Im
> >> > using PHP Version 5.2.9 in XAMPP... Hers the source...
> >> >
> >> >    public function getAllChildren($node,$level)
> >> >    {
> >> >        static $rootsarray=array();
> >> >        static $levelcount;
> >> >        $levelcount=$level;
> >> >        $child=self::getChild($node);
> >> >        if($child==''||$levelcount==0)
> >> >        {
> >> >            return 1;
> >> >        }
> >> >        else
> >> >        {
> >> >            $levelcount--;
> >> >            $rootsarray[]=$child;
> >> >            self::getAllChildren($child,$levelcount);
> >> >        }
> >> >        return $rootsarray;
> >> >
> >> >    }
> >> >
> >> > Midhun Girish
> >>
> >> Of course. The array is static. So the content is maintained between
> >> calls.
> >>
> >> You need to know when to initialize it.
> >>
> >> Something like ...
> >>
> >>  public function getAllChildren($node,$level,$firstCall=True)
> >>   {
> >>       static $rootsarray=array();
> >>       static $levelcount;
> >>       if($firstCall) {
> >>           $rootsarray=array();
> >>       }
> >>       $levelcount=$level;
> >>       $child=self::getChild($node);
> >>       if($child==''||$levelcount==0)
> >>       {
> >>           return 1;
> >>       }
> >>       else
> >>       {
> >>           $levelcount--;
> >>           $rootsarray[]=$child;
> >>           self::getAllChildren($child,$levelcount,False);
> >>       }
> >>       return $rootsarray;
> >>
> >>   }
> >>
> >>
> >> --
> >> -----
> >> Richard Quadling
> >> "Standing on the shoulders of some very clever giants!"
> >> EE : http://www.experts-exchange.com/M_248814.html
> >> Zend Certified Engineer :
> http://zend.com/zce.php?c=ZEND002498&r=213474731
> >> ZOPA : http://uk.zopa.com/member/RQuadling
> >
> >
>
> Why did you change the default to False? This now requires _ALL_ calls
> to the method to be amended.
>
> Unless you wanted to preserve the incorrect behaviour...
>
> Hmmm. BC is a PITA.
>
>
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>

--- End Message ---
--- Begin Message ---
2009/12/4 Midhun Girish <midhungir...@gmail.com>:
> hello all,
>
> hey Richard Quadling you are right... sorry man.. i just noticed that just
> now.
>
> Actually i missed th line self::getAllChildren($child,$levelcount,False);
> that you gave and thought it was a mistake...that y i updated the
> script...you can imagine the condition of a person who searched over 250
> pages in internet for this.. :)....i haven't updated the pages yet.... thank
> you for the heads up.. i will take it as you gave...
>
>
> Midhun Girish
>
>
>
> On Fri, Dec 4, 2009 at 5:48 PM, Richard Quadling <rquadl...@googlemail.com>
> wrote:
>>
>> 2009/12/4 Midhun Girish <midhungir...@gmail.com>:
>> > Hello ,
>> >
>> > Richard Quadling thank you so much.. your trick worked... :) now its
>> > working.. heres the modified code...
>> >
>> >  public function getAllChildren($node,$level,$firstCall=false)
>> >>
>> >>   {
>> >>       static $rootsarray=array();
>> >>       static $levelcount;
>> >>       if($firstCall) {
>> >>           $rootsarray=array();
>> >>       }
>> >>       $levelcount=$level;
>> >>       $child=self::getChild($node);
>> >>       if($child==''||$levelcount==0)
>> >>       {
>> >>           return 1;
>> >>       }
>> >>       else
>> >>       {
>> >>           $levelcount--;
>> >>           $rootsarray[]=$child;
>> >>           self::getAllChildren($child,$levelcount,False);
>> >>       }
>> >>       return $rootsarray;
>> >>
>> >>   }
>> >>
>> >
>> > and i call the function like :
>> >
>> >  $nodearray=tree::getAllChildren('W1',10,true);
>> >
>> >
>> > Thank you so much for your support...
>> >
>> > Midhun Girish
>> >
>> >
>> > On Fri, Dec 4, 2009 at 3:18 PM, Richard Quadling
>> > <rquadl...@googlemail.com>
>> > wrote:
>> >>
>> >> 2009/12/4 Midhun Girish <midhungir...@gmail.com>
>> >> >
>> >> > Hello guys,
>> >> > I was trying to use a recursive function to do a tree traversal.. i
>> >> > used
>> >> > a
>> >> > static array to store the nodes at each recursion.. The function
>> >> > works
>> >> > correctly if it is called only once during an execution.. but when i
>> >> > call it
>> >> > twice or more, the nodes get appended to the array...hers the var
>> >> > dump
>> >> > of
>> >> > the array...
>> >> > Three:Array ( [0] => W4 )
>> >> > Two:Array ( [0] => W4 [1] => W3 [2] => W4 )
>> >> > One:Array ( [0] => W4 [1] => W3 [2] => W4 [3] => W2 [4] => W3 [5] =>
>> >> > W4
>> >> > )
>> >> >
>> >> > I tried to reset() the array and all but not working..i am not able
>> >> > to
>> >> > chnage the index of the $rootsarray  back to 0... the new elelnts are
>> >> > added
>> >> > at the end only...can anyone give me a push in the right direction??
>> >> > Im
>> >> > using PHP Version 5.2.9 in XAMPP... Hers the source...
>> >> >
>> >> >    public function getAllChildren($node,$level)
>> >> >    {
>> >> >        static $rootsarray=array();
>> >> >        static $levelcount;
>> >> >        $levelcount=$level;
>> >> >        $child=self::getChild($node);
>> >> >        if($child==''||$levelcount==0)
>> >> >        {
>> >> >            return 1;
>> >> >        }
>> >> >        else
>> >> >        {
>> >> >            $levelcount--;
>> >> >            $rootsarray[]=$child;
>> >> >            self::getAllChildren($child,$levelcount);
>> >> >        }
>> >> >        return $rootsarray;
>> >> >
>> >> >    }
>> >> >
>> >> > Midhun Girish
>> >>
>> >> Of course. The array is static. So the content is maintained between
>> >> calls.
>> >>
>> >> You need to know when to initialize it.
>> >>
>> >> Something like ...
>> >>
>> >>  public function getAllChildren($node,$level,$firstCall=True)
>> >>   {
>> >>       static $rootsarray=array();
>> >>       static $levelcount;
>> >>       if($firstCall) {
>> >>           $rootsarray=array();
>> >>       }
>> >>       $levelcount=$level;
>> >>       $child=self::getChild($node);
>> >>       if($child==''||$levelcount==0)
>> >>       {
>> >>           return 1;
>> >>       }
>> >>       else
>> >>       {
>> >>           $levelcount--;
>> >>           $rootsarray[]=$child;
>> >>           self::getAllChildren($child,$levelcount,False);
>> >>       }
>> >>       return $rootsarray;
>> >>
>> >>   }
>> >>
>> >>
>> >> --
>> >> -----
>> >> Richard Quadling
>> >> "Standing on the shoulders of some very clever giants!"
>> >> EE : http://www.experts-exchange.com/M_248814.html
>> >> Zend Certified Engineer :
>> >> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> >> ZOPA : http://uk.zopa.com/member/RQuadling
>> >
>> >
>>
>> Why did you change the default to False? This now requires _ALL_ calls
>> to the method to be amended.
>>
>> Unless you wanted to preserve the incorrect behaviour...
>>
>> Hmmm. BC is a PITA.
>>
>>
>>
>> --
>> -----
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>
>

You really only needed 1 page ...

http://www.php.net/manual/en/language.variables.scope.php#language.variables.scope.static

Good luck!
-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
Looking for ways to add a synchronous datagrid to a php application. Any
ideas welcome. Thanks

--- End Message ---

Reply via email to