PHP mysql_pconnect() Function
Complete PHP MySQL Reference
Definition and Usage
The mysql_pconnect() function opens a persistent MySQL connection.
This function returns the connection on success, or FALSE and an error on
failure. You can hide the error output by adding an '@' in front of the function
name.
mysql_pconnect() is much like mysql_connect(), but with two major
differences:
- This function will try to find a connection that's already open, with
the same host, username and password. If one is found, this will be returned
instead of opening a new connection
- The connection will not be closed when the execution of the script ends
(mysql_close() will not close connection opened by mysql_pconnect()). It
will stay open for future use
Syntax
mysql_pconnect(server,user,pwd,clientflag)
|
Parameter |
Description |
server |
Optional. Specifies the server to connect to (can
also include a port number. e.g. "hostname:port" or a path to a local socket
for the localhost). Default value is "localhost:3306" |
user |
Optional. Specifies the username to log in with. Default
value is the name of the user that owns the server process |
pwd |
Optional. Specifies the password to log in with. Default is
"" |
clientflag |
Optional. Can be a combination of the following constants:
- MYSQL_CLIENT_SSL - Use SSL encryption
- MYSQL_CLIENT_COMPRESS - Use compression protocol
- MYSQL_CLIENT_IGNORE_SPACE - Allow space after function names
- MYSQL_CLIENT_INTERACTIVE - Allow interactive timeout seconds
of inactivity before closing the connection
|
Tips and Notes
Tip: To establish a non-persistent MySQL connection, use mysql_connect()
instead.
Example
<?php
$con = mysql_pconnect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
|
Complete PHP MySQL Reference
Reliable, affordable, feature-rich web hosting!
Take the uncertainty out of Web hosting and let
GoDaddy.com
put service, performance and value back in. No matter which
hosting type or plan you choose, your site receives 24/7
maintenance and protection in our world-class data center. Plus,
you get the expert, friendly service you deserve, from the
world's largest hostname provider.
With three plans to choose from and
prices starting at just $4.99 per month, GoDaddy.com is sure to have a plan that's
right-sized and right-priced just for you!
All plans feature FREE 24x7 setup, FREE 24x7 monitoring, best-
of-breed routers, firewalls and servers, 24x7 onsite physical security
and access to our exclusive Go Daddy Hosting Connection, THE place
to install over 30 FREE applications. Virtual Dedicated and Dedicated
Server plans also available.
Visit GoDaddy.com today.
Virtual Dedicated, Dedicated Server and unlimited plans also available.
Save 10% on web hosting - Enter code w3tenoff at checkout
|
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).
|
|