This is a simple example of how you could create a database connection from PHP to MySQL. It is good to save the MySQL Database Connection in a seperate php file in a secure part of the website. Then the file can be referenced in any page that requires a connection to the database file or This will save you from having to retype the details on every page and makes code reusable.
<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ //MySQL database hostname (i.e.: Localhost) $db_host=''; //MySQL database name (i.e. database) $db_name=''; //MySQL database username (i.e. user) $db_user=''; //MySQL database password for the user above $db_pass=''; //Initialize connection $connection = mysql_connect($db_host, $db_user, $db_pass) or die ('Error'); mysql_select_db($db_name); ?>
0 comments:
Post a Comment