Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In a file called dbconnection.php or anyother fiting name:
- <?php
- //Set strings for host, user, password and database name for access to
- //the database.
- $dbHost='localhost'; //The host name - for the time being localhost will do the job.
- $dbUser ='root'; //The name of user accessing the database - root normally has no restrictions.
- $dbPassword='password'; //Use '' if no password is set. Must be the matching user password.
- $dbName='database_name'; //Can not be NULL - you must enter a valid database name.
- //Connect to the database server.
- $dbCon = @mysql_connect($dbHost, $dbUser, $dbPassword);
- if(!$dbCon){
- echo("<p>Cannot conect to the database server.</p>");
- exit();
- }
- //Connect to the database.
- mysql_select_db($dbName, $dbCon);
- if(!@mysql_select_db($dbName)){
- echo("Cannot locate ".$dbName." database.</p>");
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement