Log in

View Full Version : sleep() pauses scripts on all pages :(



noobster
03-30-2007, 10:02 AM
Hi,

i hope there is an alternative to this problem,

i''m using a script that redirects depending on the content of a database, so it redirects on page 1 if data 1 exists or page 2 if data 1 doesn't exist.

so i needed a php script to verify that, the page shows at the moment before redirecting for
SLEEP(15);

but i also use this website to admin a few things, and when i access my datas, al my php scripts seem to suffer from that SLEEP function!!

I thought it woud only affect the current running script from the page that calls the sleep function.

Is there an alternative? ( i can't call a loop to make a timer, it loads the cpu too high)

javascript redirection won't offer me a database check..

so does anybody have a idea?

thanks a lot in advance.

codeexploiter
03-30-2007, 10:16 AM
What about performing a redirect using Javascript using PHP?

Something like the following



if(somecondition == true)
{
echo "<script type='text/javascript'>window.location.replace(\"yourrequiredpage.extension\");</script";
}

tech_support
03-30-2007, 10:25 AM
You could also change

if(somecondition == true)
to
if(somecondition)

noobster
03-30-2007, 10:56 AM
What about performing a redirect using Javascript using PHP?


well that's what i'm using but i 'm using Sleep() to timer the page change according to this.

i want to have page wait 15 seconds before redirecting.

i can't use javascript redirect or i don't know how using php condition.

Does one you two know?

thanks already for your answers.

nb: i don't get the if statment, isn't that what i already use?

i could post my scripts if needed.