We just need to create a file config.php
and have the code
<?php
//Database Constants
define(”DB_SERVER”, “localhost”);
define(”DB_USER”, “english_wefri”);
define(”DB_PASS”, “winnerlabel”);
define(”DB_NAME”, “english_wefriend”);
?>
then create a file which is called connection.php
and put the code in the file.
<?php
require(”constants.php”);
// 1.Create a database connection
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if(!$connection){
die(”Database connection failed:” . mysql_error());
}
// 2.Select a database
$db_select = mysql_select_db(DB_NAME,$connection);
if(!$db_select){
die(”Database selection failed: ” . mysql_error());
}
?>
Then we just connect the our site to the database.
And we can put different kinds of code after that in the <head> & </head> as well as <body> </body> party.
After finish that we shall close the database,we just need to create another file which is called footer.php
we just need to put the code
</div>
<div id=”footer”>Copyright 2007,Widget Corp</div>
</body>
</html>
<?php
if(isset($connection)){
mysql_close($connection);
}
?>
within the footer.php
so this three files help us with create a connection the our database and disconnect ourdatabase.
Leave a comment
You must be logged in to post a comment.