Is you head spinning from reading over all of the preliminary planning and trying to figure out which data types to use? On to some actual coding... but first... you need to know or find out a bit more information called host, username, and password.

The HOST value is usually set as localhost. You may want to check your host server's FAQ/HELP area or email them to be sure.

The USERNAME and PASSWORD are relatively easy considering they are the same ones you use to log onto your hosting account normally.

Now you should be ready to create your first database with the help of PHP. This example shows three parts to do this.

The first section declares your basic variables. These let you easily use them throughout the rest of the coding.

The second section connects to the database server. We are using a variable to activate a MySQL command. The variable will hold a positive or negative value depending on the successful connection or not. mysql_connect is the database command to connect to the database server using the initial settings.

The third section is doing a few things. First it is altering the value of the database name. On some systems, the databases are arranged in a "UserName_DataBaseName" setup. Thus to be compatible, the script is creating this effect for us. The example will produce a database file called "david_test".

The next line is using an IF statement. If the statement holds a true value (being a negative result from the query), it will stop the current script (die) and print out the specific SQL error. mysql_query is the command being used to activate the specified information which happens to be to CREATE a DATABASE called test. As long as this line did not "die", the last echo command will print out a successful creation.

Table of Contents

Column Modifiers