Hi Everybody,

I'm posting this after 10 hours of trial and error, hope someone has an idea...

What I'm trying to do is make thumbs out of numerous images, and it works for a small number of images (a few) but for anything more max_execution_time is exceeded (and i cannot edit php.ini on this host).

Here's how it basically looks:

$result = $mysqli->query("SELECT image_filename FROM my_table");
while ($row = $result->fetch_assoc())
{

 [I]here is simply a call to the class that makes thumbs,
it's http://phpthumb.gxdlabs.com/ if anyone familiar - and I recommend you
check it out if you need easy image handling, you might find it very useful[/I]

echo 'one more thumb is made';

}

echo 'success';

Now, the way I see it, this should keep writing 'one more thumb is made' while the process lasts, and give me 'success' message at the end.

But instead, there's no change on screen until the process is completely through, and when it is, I get...

1) If i feed it with few images, say 3, I'd get

one more thumb is made
one more thumb is made
one more thumb is made
success

2) if i feed it with 100-200 images, I'd get (after a lot of waiting)

one more thumb is made
one more thumb is made
one more thumb is made

and 2 errors

HTTP request failed and
max_execution_time (60sec)exceeded.

Again, i have no access to php.ini here.


Thanks a lot for reading through, any solutions?

Member Avatar for diafol

You are making 200 calls to a thumbnail producer? I'd use Ajax to group your processing into say 10's, giving an update to the screen after each set of 10. This should avoid the timeout problem.

I'm not an expert in ajax, but I'd try something like this:

1. html link to call js script (firstCall - runs doThumbs(1)) - where 1 = first record to return
2. doThumbs(num) calls a php script to do the processing - the num parameter is passed to it for the LIMIT clause.
3. the doThumbs(num) receives json data - 1) screenoutput 2) startnum for iterating doThumbs() until startnum = 'end' or whatever.

Thanks for the inspiration.

I tried it, didn't work. Then I even tried refreshing the entire page for each single thumb made, and to my surprise, I again got the same result - few thumbs done and timeout error.

I've never been on a single issue this long (2 days+) - any help appreciated!

You can change the max execution time in php script

<?php
ini_set('max_execution_time',500000000000);
ini_set('max_input_time',500000000000);
echo ini_get('max_execution_time');
?>
Member Avatar for diafol

I don't understand why the ajax option didn't work as each call to the php script is distinct - no hangover from previous. Odd.

Thanks mahavir123 for directing me,
that also didn't work for me for some reason max_execution_time stayed 30
Guess it has to do with server settings and permissions.

What did finally work for me (if anybody comes into same issue) is
putting this into .htaccess file:

php_value max_execution_time 2000
php_value max_input_time 2000

And thanks ardav too.
Yes, your solution sounds totally realistic, maybe I didn't implement it right,
happens when you hit your head with one issue all day.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.