PHP mysql_connect () to establish and close database connections
Resource Mysql_connect
([string hostname
[:p ORT] [:/path/to/socket]
[, String Username] [, String password]])
All parameters are optional
Example:
- @mysql_connect ("localhost"
, "User", "password")
- Or Die ("Could not Connect
Note that the @ symbol represents any error message that is caused by a forbidden failed attempt, and the user will see the error message specified in die ().
Note that when connecting to multiple MySQL, you must specify the link ID for each connection, as follows:
- $ Link1 = @mysql_connect
("Server1", "User", "password")
- Or Die ("Could not connect to
MySQL server! ");
- $ Link2 = @mysql_connect
("Server2", "User", "password")
Connect to MySQL server! ");
PHP Mysql_pconnect () to establish and close database connections
- Resource Mysql_pconnect
([string hostname [:p ort]
Unlike mysql_connect (), the existing link is first found and is not created until it exists.
Note that you do not need to display a close connection (Mysql_close ()) because the connection will be placed in the pool, so it is called a persistent connection.
PHP mysql_close () to establish and close database connections
- Boolean mysql_close
Closing a connection is not necessary because it can be handled by MySQL garbage collection.
If link_id is not specified, the closest link is closed.
http://www.bkjia.com/PHPjc/446137.html www.bkjia.com true http://www.bkjia.com/PHPjc/446137.html techarticle PHP establishes and closes the database connection mysql_connect () resourcemysql_connect ([Stringhostname [:p ort][:/path/to/socket] [, Stringusername][,stringpassword]]) All parameters are optional ...