MySQL Connection: How to connect with a database server?Tag: mysql, database Category: Mysqlpost: 31 Oct 2007 read: 1,059 This is basic tutorial about connection to MySQL database server. I will show to you how to connect to you database server for first time. You can use mysql database connection with mysql_connect() function. For Example, like below
mysql_close() function is optional. The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close(). little more deep: mysql_connect() establishes a connection to a MySQL server. The following defaults are assumed for missing optional parameters: server = 'localhost:3306', username = name of the user that owns the server process and password = empty password. Another option, you can use mysql_pconnect(). mysql_pconnect() acts very much like mysql_connect() with two major differences. First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection. Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()). The optional client_flags parameter became available in PHP 4.3.0. |
| | Give Your Opinion | Recommend |
|

