HOME | basics of HTML | basics of PHP | neobux | onbux | readbud | templates |
| ||||||||||||
PHP MySQL Connect to a Database
PHP MySQL Connect to a DatabaseThe free MySQL database is very often used with PHP. Create a Connection to a MySQL DatabaseBefore 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
Note: There are more available parameters, but the ones listed above are the most important. Visit our full PHP MySQL Reference for more details. ExampleIn 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 ConnectionThe connection will be closed automatically when the script ends. To close the connection before, use the mysql_close() function:
|
||||||||||||
© 2011 d4download.orgfree, All Rights Reserved.
Design created by diljith d4download veriosn 2.0
HOME | basics of HTML | basics of PHP | neobux | onbux | readbud | templates |