How to set timeout when php connects to the MySQL database

Source: Internet
Author: User
When php connects to the MySQL database, how to set the timeout to use the mysql_connect function will return failure if the connection exceeds the set time. How do I set this ?!, Let's take a look at the document. If php times out, the server will respond. set_time_limit (25); if it times out in your mysql_connect function, an error will be reported & nbsp; how to set timeout when php connects to the MySQL database
When the mysql_connect function is used, failure is returned if the connection fails after the set time.

How do I set this ?!

------ Solution --------------------
Let's take a look at the document. If php times out, the server will respond.
------ Solution --------------------
Set_time_limit (25 );
If it times out in your mysql_connect function, an error is returned.
You can use try catch to wrap your mysql_connect function.
I only wish you good luck.

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.