PHP - What is the difference between mysql_connect() and mysql_pconnect()?

What is the difference between mysql_connect() and mysql_pconnect()?

When mysql_pconnect() is used, the function initially tries to find an open persistent connection. If found; the identifier is returned. In this case, a new connection is not established. On the other hand, when mysql_connect() is used, a new connection is established.

Using mysql_pconnect(), the connection is not closed to enable future use.

Example:
mysql_pconnect("localhost","mysql_user","mysql_pwd");

What is the difference between mysql_connect() and mysql_pconnect()?

The following are the differences -

- A new connection is established to the database by using mysql_connect, where as mysql_pconnect opens a persistant connection to the database.

- mysql_connect can be used to close the connection, where as mysql_pconnect can not close the connection.

- Database is opened every time when the page is loaded by mysql_connect. Whereas by using mysql_pconnect, database need not be connected every time.
PHP - Explain with code how to get a user's IP address.
Explain with code how to get a user's IP address - The users IP address can be returned by specifying the host name as aparameter in gethostbyname(“hostname”) method....
PHP - Explain with code how to generate a random number from php.
Explain with code how to generate a random number from php - The function rand() can be used to generate random number....
PHP - Explain about Type Juggling in php with an example
Explain about Type Juggling in php with an example - The ternary conditional operator is of the form.....
Post your comment