hi everyone.

please tell me difference between
mysql_connect & mysql_pconnect?

and which is better and how?

Member Avatar for diafol

The 'p' stands for persistent. That is it keeps a connection open to the server even after the query has been processed. mysql_close doesn't affect it. It's sometimes used to avoid creating a new connection, as an old persistent connection can be used, therefore improving efficiency.

However, I have never found the need to use it (my servers are never under enough pressure to warrant the use). However, if you use pconnect and have limits on the number of open persistent connection you can have to your DB, it could prevent new connections. Table/transaction locking can also cause problems for p connections. If you get an infinite loop (which I assume we all have from time to time when testing), you may require a server restart.

If your db loading's ok, don't bother.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.