What are the differences between mysqli connect and mysqli pconnect

0 votes
What is the main difference between them? Can anyone explain me with any sample code?

thank you!!
Mar 27, 2020 in PHP by kartik
• 37,530 points
1,596 views

1 answer to this question.

0 votes

Hello,

mysqli_pconnect() function is used for making a persistence connection with the database that does not terminate when the script ends.

mysqli_connect() function searches any existing persistence connection first and if no persistence connection exists, then it will create a new database connection and terminate the connection at the end of the script.

Sample code:

$DBconnection = mysqli_connect("localhost","username","password","dbname");

// Check for valid connection

if (mysqli_connect_errno())

{

echo "Unable to connect with MySQL: " . mysqli_connect_error();

}

mysqli_pconnect() function is depreciated in the new version of PHP, but you can create persistence connection using mysqli_connect with the prefix p.

Thank You!!

answered Mar 27, 2020 by Niroj
• 82,880 points

Related Questions In PHP

0 votes
0 answers

What are the differences in die() and exit() in PHP?

I think both have the same functionality, ...READ MORE

Apr 8, 2020 in PHP by kartik
• 37,530 points
172 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
3,389 views
0 votes
1 answer

What are the best way to allow plugins for a PHP application?

Hii, Here is an approach I have  used, it's ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,880 points
258 views
0 votes
1 answer

Error: “The zip extension and unzip command are both missing, skipping.”

Hello @kartik, Depending on your flavour of Linux ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,880 points
3,054 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
265 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
855 views
0 votes
1 answer

How to get thumbnail of youtube video from youtube API?

Hii @kartik, If you want the biggest image ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,880 points
867 views
+2 votes
1 answer

Error: laravel.log could not be opened?

Hello, Never use 777 for directories on your ...READ MORE

answered Apr 2, 2020 in Laravel by Niroj
• 82,880 points
9,418 views
0 votes
1 answer

What are the vulnerability related to PHP Form?

Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,880 points
715 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
885 views