Create a Connection to a MySQL Database
Before you can access data in a database, you must create a connection to
the database.
In PHP, this is done with the mysql_connect() function.
Syntax
Example
In the following example we store the connection in a variable ($con) for later use in the
script. The "die" part will be executed if the connection fails:
Closing a Connection
The connection will be closed automatically when the script ends. To close the
connection before, use the mysql_close() function: