Posted on April 20th, 2012
2564 views
The database connection file
In this file we will be creating the database connection file, so that our code can communication with the database. First of all, we need to create the database, so simply go into your MySQL Manager (phpMyAdmin maybe?) and create a database and user and allow all of the privaleges then go to the database in phpMyAdmin and click the SQL tab and insert this MySQL Code...
CREATE TABLE IF NOT EXISTS `files` ( Now that we have our database all setup, we can now make the file that connects to the database. In the dbcon.php file we created earlier simply just put this code in it, its got comments to help you understand what the different parts do.
<?php $dbhost = "localhost"; // this will ususally be 'localhost', but can sometimes differ $dbname = "dlsys"; // the name of the database that you are going to use for this project $dbuser = "dlsys"; // the username that you created, or were given, to access your database $dbpass = "pass"; // the password that you created, or were given, to access your database mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error()); mysql_select_db($dbname) or die("MySQL Error: " . mysql_error()); ?>
Now you can save this file and move on to the next chapter, The index file.
|