top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between MySQL_connect and MySQL_pconnect?

–1 vote
549 views
What is the difference between MySQL_connect and MySQL_pconnect?
posted Mar 13, 2017 by Navya

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Mysql_connect:

It opens a new connection to the database.
Every time you need to open and close database connection, depending on the request.
Opens page every time when it loaded

<?php
    mysql_connect('servername','username','password');
    mysql_select_db("db_name");
?>

Mysql_pconnect:
In Mysql_pconnect, "p" stands for persistent connection so it opens the persistent connection.
The database connection can not be closed.
It is more useful if your site has more traffic because there is no need to open and close connection frequently and every time when page is loaded.

<?php
       mysql_pconnect('servername','username','password');
       mysql_select_db("db_name");
?>
answer Mar 14, 2017 by Arun Angadi
...