is it possible to wait for 20 secs before it run the script?
I mean I try set_time_limit(20) but when I click the button, it always run the script.
I guess the time limit was just for the time limit when the script running then it will stop.
im looking for a function that can help me for my script to wait for 20 secs. I know it will work on jQuery but im holding right was Yii framework.
I have sample script below
$coco = mysql_query( "SELECT * FROM gameWaiting" );
if ( empty( $coco ) ) {
mysql_query( "INSERT INTO gameWaiting VALUE('', '$email', '$language')" );
$status = 0; // IF THE STATUS is equal to 0 means the db was empty so it will insert
// AND WAIT FOR OTHER PLAYER TO INSERT ALSO
} else {
mysql_query( "INSERT INTO gameWaiting VALUE('', '$email', '$language')" );
$status = 1; // IF THE STATUS is equal to 1 means the db was !empty so it will insert also
// BUT THERE is no need to wait for other player otherwise RAND() the user.
}
// NOW SET TIME HERE when it will INSERT to the game
if ( time was equal to set) {
// IF SOMEONE insert into gameWaiting it will create game
mysql_query( "INSERT INTO game VALUE('','name','email','language')" );
} else {
// No player was added
}
echo $status;
I hope this is possible…
set_time_limit()specifies the maximum execution time for the script, not the time to wait until executing it (see the Docs).You can use PHP’s
sleep()function to force execution to delay by a given number of seconds: