Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
layarmmo-database [2012/11/07 17:59]
matthewleach Making a start at adding details.
layarmmo-database [2012/11/09 12:16]
matthewleach Some more instructions added.
Line 1: Line 1:
-== Creating the Database ==+=== Creating the Database ​===
  
 The steps for setting up your database will depend on the setup of your server, but we'll briefly look at the steps for cpanel users. ​ After logging in you are looking for the databases section: The steps for setting up your database will depend on the setup of your server, but we'll briefly look at the steps for cpanel users. ​ After logging in you are looking for the databases section:
Line 5: Line 5:
 {{:​cpanel-db.png?​nolink|}} {{:​cpanel-db.png?​nolink|}}
  
-If the wizard is available, then you may as well use it.  Just be sure to notedown any names or passwords that you enter. ​ The stages for me were:+If the wizard is available, then you may as well use it (2nd option from left).  Just be sure to notedown any names or passwords that you enter. ​ The stages for me were:
  
   - Choose a name for the database (keep it short but meaningful, like "​mmo"​). ​ Note there may be a prefix linked to your account - like "​account_"​. ​ If there is then your database name is actually "​account_mmo"​.   - Choose a name for the database (keep it short but meaningful, like "​mmo"​). ​ Note there may be a prefix linked to your account - like "​account_"​. ​ If there is then your database name is actually "​account_mmo"​.
-  - Create a user and a password. ​ Again the username may have a prefix set for it, so be sure to note down the whole name.  ​There may be a chance to generate a password ​which will be insanely secure +  - Create a user and a password. ​ Again the username may have a prefix set for it, so be sure to note down the whole name. 
 +  ​- ​Set privileges. The recommended settings are shown in the image below.
  
  
-Database name; user name and password; rights on database+=== Creating Tables ===
  
-Setting up with phpMyAdmin.\\ +phpMyAdmin ​is a great interface for working with your database, so hopefully you have it installed on your server If you return to cpanelthen you should be able to find the icon to click on.
-3 tables: user detailsspawned monsters, monster details+
  
 +Depending on how your server is setup, clicking on the icon may automatically take you into phpMyAdmin as the administrative user.  If you are presented with a login screen, then use the database username and password that you just created.
  
-The database ​information ​file (dbinfo.php):+We are going to start with 3 tables:  
 +  * user details - the people using your game  
 +  * monster details - the types of monsters in your game 
 +  * spawned monsters - details for each monster that actually exists in your game 
 +   
 +=== Creating a Database Connection File === 
 + 
 +To make things easier for ourselves, We can put the code to connect to the database ​in a separate ​file.  Copy and paste the code below into a new file, changing the database name, user name, and password to your own settings. ​ $dbhost will stay as locahost in most cases. ​ Save it as dbinfo.php.
  
 <code php> <code php>
Line 24: Line 32:
 // Pre-define connection to the MySQL database, please specify these fields. // Pre-define connection to the MySQL database, please specify these fields.
 $dbhost = "​localhost";​ $dbhost = "​localhost";​
-$dbdata = "database"; +$dbdata = "account_database"; 
-$dbuser = "username";+$dbuser = "account_username";
 $dbpass = "​password";​ $dbpass = "​password";​