Database operation delay PHPcodeecho & quot; & lt; Scriptlanguage = 'javascript '& gt; alert ('data detection completed! '); & Lt;/Script & gt; & quot; echo & quot; & lt; SC database operation delay
PHP code
echo ""; echo ""; sleep(10); mysql_query("delete from `".$p."` where rkno = '".$rkno."'");
My idea is to return to the corresponding page before deleting the database. The effect of the code is to wait 10 seconds to delete the data, but stay on the current page. What's wrong?
------ Solution --------------------
The output may be cached by the server.
Flush (); // clear the cache
Sleep (10 );
------ Solution --------------------
Flush (); // launches cache
This is necessary. for ie-compatible browsers, a total of more than 256 bytes of content must be sent before execution, unless the program ends.
However, your writing method is risky.
Once
If it is executed, the user terminates the connection of the current program, and php terminates the execution of the current program by default.
Mysql_query ("delete from '". $ p. "'Where rkno ='". $ rkno ."'");
There is no chance to execute it.
------ Solution --------------------
What about this ??? In addition, there are differences between different browsers, so chrome may not work.
Ini_set ('output _ buffering ', 'on ');
Ini_set ('zlib. output_compression', 0 );
Echo "";
Echo str_pad ("", 1024 );
Ob_flush ();
Flush ();
Sleep (10 );
Mysql_query ("delete from '". $ p. "'Where rkno ='". $ rkno ."'");
......