Knowledge Database

Everything you ever wanted to know. (well almost...)

Didn't find what you we looking for?
Why not ask one of our online staff or drop us a message!

Tutorials > MySQL Database > MySQL Database Introduction



MySQL Database Introduction

MySQL is an extremely powerful database application. Its performance generally outstrips Microsoft SQL, is less resource intensive and is completely free to license. MySQL is RSAWeb's primary Web Hosting database of choice and at least one comes standard with every Standard Linux hosting package. You can create a new database on your hosting through the MyRSAWeb Control Panel, this will give you full access to your new database with full usernames and randomly generated secure passwords. A simple database connection string is set out below.

// connect to the database server with username and password
mysql_connect($username,$password,$hosting);

// open a database
mysql_select_db($databasename);

// run a select query against an existing table of information. $sql is the SQL query. store the returned data in the $result variable.
$sql = "SELECT * FROM testtable WHERE id='1'";
$result = mysql_select($sql);

// get the number of records (rows)
$numberofrows = mysql_num_rows($result);
echo "<br>Number of results: " . $numberofrows;

// get the data from the first record returned from the SQL query
$row = mysql_fetch_array($result);

//
echo "TestData: " . $row[column];

mysql_close();
That is the basis of connecting to a webhosting server. There are vastly more complicated ways of doing the same query as above with error checking, data checking etc to prevent any errors breaking the page and generating an error. You can get more information on the RSAWeb Web Hosting Support site or go to the MySQL homepage www.mysql.com m00

Similar Information from this category