Database operation delay problems

Source: Internet
Author: User
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 ."'");
......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.