The first part of this tutorial is located here. At this point, you should have a new database with a user that has been added to it.
The next part of the tutorial gets a bit more computer-science oriented. If you haven’t worked directly with SQL this isn’t the best tutorial for you. It is intended for people who have some coding experience but don’t know how to make a site go live (beyond localhost on their own computer).
I will now request that you return to the cPanel homepage. The next step is to set up a website and make it so that you can access your database. To do so, begin by clicking on “subdomains.” Here I circled it in red:
Once there, create a new subdomain. This will be the location of your new site. I’m pretty sure I left “document root” blank and let it fill something in for me. Once you’ve created your subdomain, it should appear in a list at the bottom of the page. Click on the link to its document root. Mine looks like this:
This is where the files that make up your site are going to be. In the upper left, there is a tool that says “new file.” Click on it. Name the file “db_connect.php.” It should now appear in your list of files. Right click on it and select code editor. This is where you get to grant yourself permission to access the database. You’re going to want to type in the following code:
$db = mysql_connect(‘localhost’, ‘username’, ‘password’)
or die (mysql_error());
mysql_select_db(“databasename”) or die(mysql_error());
Instead of username, password, and databasename, enter the information for the user and database you created in the last tutorial. You don’t have to include “session_start();” but it’s a good idea. You’ll want to put
<?php include(‘db_connect.php’); ?>
at the top of every file you create, so starting a new session is something you’d want to do anyway. Save the file. Now you should be able to use MySQL queries in your files that include db_connect.php. If you want to manually manipulate your database instead of using queries in your code, you can go to phpMyAdmin from the cPanel homepage:
One last note: The default homepage for your site is called index. I think mine was in there as index.php. That’s the best place to start. Good luck!