< ?php
/* Created BY Vincent Amedekah
This a simple script l've created to help anyone who might need help connecting to database in php
Things to look out for
1: "die()" will exit the script and show an error statement if something goes wrong with the "connect" or "select" functions.
2: A "mysql_connect()" error usually means your username/password are wrong
3: A "mysql_select_db()" error usually means the database does not exist.
*/
/* database hostname is the computer running the server, it's local host in some cases, find this information from your hosting provider */
$db_host = "localhost";
/* Place the username for the MySQL database here */
$db_username = "username";
// Place the password for the MySQL database here
$db_pass = "yourpassword";
// Place the name for the MySQL database here
$db_name = "yourdatabasename";
// Run the actual connection here
mysql_pconnect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");
?>
/*
It’s simple and easy to get done. the best thing will be to save this file in separate file so that any time you need to connect to the database on a particular page, you simple require or include it in php.
Assume you save this file in a file called databaseconnection.php, you can get access to the database by simply issue the command include “databasconnection.php”. After this, you can simply run your queries from the database. For example, if l have a table in my database called users, l can select all information about users by simply running the query mysql_query(‘select * users’);
*/