What is mysql pconnect in PHP

In this article I am going to explain about mysql_pconnect function in PHP.
  • 2038

PHP mysql_pconnect() Function

The PHP mysql_pconnect function opens a persistent connection to MySQL database from php script. The advantage of mysql_pconnect over mysql_connect function is that, you do not need to close the connection like mysql_connect function and it also keeps the connection live even the script execution is over.

Syntax of mysql_pconnect function

mysql_pconnect(server, user, pwd, clientflag)

Parameters in mysql_pconnect function

It have four parameter:

Parameter Description
server It specifies mysql server name.
user It specifies username for login.
pwd It specified password for login.
clientflag Clientflag parameter can be combination of many of constants.

Example of mysql_pconnect function

<?php

$con=mysql_pconnect("localhost","gupta","sharad");

if(!$con)

{

die("Could not connect:".mysql_error());

}

else

{

echo "Connection established successfully";

}

//Here you do not need to close the connection.

?>


Output:

mysql-pconnect-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.