Jump to content

Recommended Posts

I have a page that queries a MySQL database to retrieve words in order to build a crossword puzzle.  The page displays my standard header and the empty grid, then starts the process.  I have logic to control how many iterations of the outermost loop is executed.  When it hits the max, it displays the filled-in grid to show how far it's gotten.

 

The PHP program, or page (or browser??) times out after one minute.  If I put in a smaller iteration limit (one that completes in less than a minute), the program displays the grid showing the progress.

 

I've played with the various "timeout" settings I can Google that relate to PHP and MySQL, but nothing I've done seems to alter the 1 minute processing limit.

 

Help!

-Dan-

Link to comment
https://forums.phpfreaks.com/topic/144855-page-timing-out/
Share on other sites

The browser is probably timing out. You can use ob_flush and flush to output items to the browser in iterations, say every 10 loops you echo a "." to the browser.

 

Here is an example of that:

<?php
set_time_limit(0); // unlimited

for ($i=0;$i<10000;$i++) {
    if (($i%100) == 0) {
          echo '.';

          ob_flush();
          flush();
   }    
}
?>

 

This will only work in certain browsers. I know it works on FF 3+.

 

See if that helps you out at all.

Link to comment
https://forums.phpfreaks.com/topic/144855-page-timing-out/#findComment-760147
Share on other sites

I already had the max_execution_time set to 300 (5 minutes) in my php.ini, so that was already set.

 

The other suggestion (using the echo and ob_flush/flush) extended the execution time to about 2-1/2 minutes, but it still terminated at that time.  Btw, I'm using FF 3, and haven't tried it on other browsers yet.  So it helped a bit, but I'd love to have it set up to run 5, 10, 20 or even 30 minutes (if needed).

 

Thanks for the suggestions!

-Dan-

Link to comment
https://forums.phpfreaks.com/topic/144855-page-timing-out/#findComment-760256
Share on other sites

I already had the max_execution_time set to 300 (5 minutes) in my php.ini, so that was already set.

 

The other suggestion (using the echo and ob_flush/flush) extended the execution time to about 2-1/2 minutes, but it still terminated at that time.  Btw, I'm using FF 3, and haven't tried it on other browsers yet.  So it helped a bit, but I'd love to have it set up to run 5, 10, 20 or even 30 minutes (if needed).

 

Thanks for the suggestions!

-Dan-

 

Using the PHP CLI and extending the max execution time to 30 minutes, this should be possible.

 

As for running it in the browser, it is not probable, due to memory on the side with the browser etc.

Link to comment
https://forums.phpfreaks.com/topic/144855-page-timing-out/#findComment-760264
Share on other sites

Thanks so much for your help!  I'm a newbie to php and wasn't aware you could execute php from the command line.  I actually just migrated from PC to Mac (wow!), and you set me on a path to using the Mac command line, and installing php and MySQL locally, etc.  This will help me keep my development environment separate from my website, too (especially if my admin web page could pull data from my Mac and post it to my web server!).

 

I'm optimistic that approach will help me crack this nut.  (Unfortunately, I'm an old dog at programming and just see too many options right now!)

 

Thanks again,

-Dan-

Link to comment
https://forums.phpfreaks.com/topic/144855-page-timing-out/#findComment-760689
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.