Jump to content

[SOLVED] PHP Timeout solution?


andrewgarn

Recommended Posts

OK some people here might remember me requesting a solution to my update pages timing out. I have attempted solutions but have come to the conclusion it might be the server, which ive found to be horribly unreliable, (from php query and the internal phpmyadmin)

 

THe update pages cycle through a list of users and update them if the last update time isnt today.

 

Well i thought of a possible solution to the problem, could this work, and if so, how?

 

1. Load page

2. page updates first row

3. page refreshes to itself and updates 2nd user

4. repeat no.3 until end of table.

 

5. stop and output results

 

How could i get this to work, is it feasibile? My user table doesnt currently contain an autoincrementing column.

 

The scripts use queries that take data from url file access, and 2 other tables.

 

Would this fix timeout? if it reloaded the page for each user?

 

Thanks, if you dont understand please post a question

Link to comment
https://forums.phpfreaks.com/topic/113112-solved-php-timeout-solution/
Share on other sites

instead of reloading the page for each user you can use the set_time_limit() or max_execution_time() methods. by default your scripts will try to run in 30 seconds then timeout, this wont work if you have a huge database to process obviously.

 

heres an example:

 

set_time_limit(3600); gives your script 3600 seconds to run  :)

instead of reloading the page for each user you can use the set_time_limit() or max_execution_time() methods. by default your scripts will try to run in 30 seconds then timeout, this wont work if you have a huge database to process obviously.

 

heres an example:

 

set_time_limit(3600); gives your script 3600 seconds to run  :)

 

Sorry i was eating.

 

I tried that previously with set_time_limit(9999); the pages still timed out in 30seconds.

You can just pass the current row number or whatever row is next to the page through get. If you don't know for sure how to identify the next row, I think something like this will work:

"UPDATE [...] LIMIT 1 OFFSET ".$_GET['currentrow']";
header("Location: ?currentrow=".$_GET['currentrow']++);

 

I think LIMIT and OFFSET work in UPDATE, but I've never tried it. You could so a SELECT subquery if it doesn't.

You can just pass the current row number or whatever row is next to the page through get. If you don't know for sure how to identify the next row, I think something like this will work:

"UPDATE [...] LIMIT 1 OFFSET ".$_GET['currentrow']";
header("Location: ?currentrow=".$_GET['currentrow']++);

 

I think LIMIT and OFFSET work in UPDATE, but I've never tried it. You could so a SELECT subquery if it doesn't.

 

Is there any way to add an auto inc column to a table after its created and has data in it?

 

I'd still like a solution without the refreshing if possible.

What kind of server are you using? Do you have access to the configuration?

 

www.freehostia.com

 

no access to configuration I dont think, but its the only server I could find with my requirements:

 

url file access, mysql, etc

 

waiting for ad revenue to pay for hosting.

So the only solution is the refreshing page?

 

That is my guess. You could do more than one per refresh though. Is this a script that users will be executing or just something that needs to be done manually to set things up? If it is the latter, you could set up a server on your own computer and run it from there.

So the only solution is the refreshing page?

 

That is my guess. You could do more than one per refresh though. Is this a script that users will be executing or just something that needs to be done manually to set things up? If it is the latter, you could set up a server on your own computer and run it from there.

 

Well i have 3 scripts, 2 of them are currently run manually once a day

 

the other needs to be run every hour throughout the day

 

users of the site have no access to these pages.

Got a techincal support reply from server about set_time_limit()

 

Hello,

 

Thank you for contacting our Technical Support Department.

 

No it's not disabled, but you can't change this value.

 

Best Regards,

James

Ha! That is such a great answer.

 

So you either have to make your scripts take less than 30 seconds or execute them from a different place. I would recommend setting up a server and doing the two that are manually done on your own server where you can set the timeout.

Got a techincal support reply from server about set_time_limit()

 

Hello,

 

Thank you for contacting our Technical Support Department.

 

No it's not disabled, but you can't change this value.

 

Best Regards,

James

Ha! That is such a great answer.

 

So you either have to make your scripts take less than 30 seconds or execute them from a different place. I would recommend setting up a server and doing the two that are manually done on your own server where you can set the timeout.

 

Unfortunately the mysql server being used is internal to the server, and cant be accessed from outside, so i'm stuck with the server.

 

I made a new post about the refreshing solution

I had a problem similiar to yours once. My solution was to create an external file with a list of mysql queries that needed to be executed. Then I read that file line by line and as each one was completed, I removed that line and resaved the file. That way, if the script does timeout. The next time it is run, it continues working on the same project without replicating work.

I had a problem similiar to yours once. My solution was to create an external file with a list of mysql queries that needed to be executed. Then I read that file line by line and as each one was completed, I removed that line and resaved the file. That way, if the script does timeout. The next time it is run, it continues working on the same project without replicating work.

 

Not sure that would work for me, these pages need to be run every day, and should be automatic without my help if possible

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.