Sourabh
Sourabh

Reputation: 1765

Forcing a php script to run

I have a php script that is looping on a huge directory of data. What it does is looping through record ids, if it doesn't find anything useful, it increment the id and redirect to same page with new id. I want to force run this script to get the data for me, but after every 20 records, its stopping and giving error that this script is not redirecting properly. is there any way of altering php.ini file using which I can force this script. Its running as it is supposed to run and its supposed to redirect like that.

Upvotes: 0

Views: 58

Answers (2)

AndreKR
AndreKR

Reputation: 33678

You are hitting the HTTP redirect limit. The default for Firefox is 20.

You could use a meta redirect or a Javascript redirect, which are exempt from this limit.

Upvotes: 2

dtbarne
dtbarne

Reputation: 8200

It sounds like your use case should use PHP CLI with a main while/for loop, rather than redirecting to itself.

Of course, you could use a main while/for loop in the browser as well and just set_time_limit(0) to remove the time limit restriction.

It's also worth noting that the limitation you're seeing is enforced by your browser, not by your web server, so modifying php.ini will not affect this.

Upvotes: 0

Related Questions