1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Large recursive script problem

Discussion in 'PHP' started by Weirfire, Feb 5, 2005.

  1. #1
    I'm running a script which is recursive and seems to blank out at around the 2300th time. I need it to run approximately 5000 times.

    Any ideas how to stop it timing out?
     
    Weirfire, Feb 5, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    What language is it?
     
    digitalpoint, Feb 5, 2005 IP
  3. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Post the code/function. Is it timing out or is it meeting some exit condition?
     
    exam, Feb 5, 2005 IP
  4. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #4
    It was in PHP.

    I've adjusted the number of times it has to run to less than 2000 so it now works properly.
     
    Weirfire, Feb 5, 2005 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #5
    You could set your timeout to no limit with:

    set_time_limit(0);
    PHP:
    but it's probably better to keep resetting the remaining time limit with each cycle (in case something does happen it doesn't hang forever) with the same command (but set it to something). Each time you call it, it will reset the remaining limit.
     
    digitalpoint, Feb 5, 2005 IP
  6. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #6
    Hmmm thanks for that. I would eventually have to reduce the time of each execution anyway but it is helpfull if you want to find if a certain part of a program works.

    If I wasn't hacking my code then I would already know whether it was going to work or not.

    I'm on to another bizarre problem.


    The code is something like this

    Neither $B or $C has any value but $A shows the proper value. Do I need to give each function a type? It just doesnt seem to be passing the data back in the return statement.
     
    Weirfire, Feb 5, 2005 IP
  7. sarahk

    sarahk iTamer Staff

    Messages:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #7
    works for me...
    <?php
    function getA()
    {
    	$A = 4;
    	return $A;
    }
    
    function getB()
    {
    	$B = getA();
    	return $B;
    }
    ?>
    <body>
    <?php
    $C = getB();
    echo $C;
    ?>
    Code (markup):
     
    sarahk, Feb 6, 2005 IP
  8. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #8
    Yeah, I tried the simple program and it worked.

    I'll just have to break it apart bit for bit until I find the problem. lol
     
    Weirfire, Feb 6, 2005 IP