Brinkster Knowledge Base

KB Home   /  Support  /  Database  /  MySQL  /   Database Connection Strings - Linux Hosting
Database Connection Strings - Linux Hosting Articles
Database Connection String Samples

Important information regarding the following code samples.

All references to "mysql_user" need to be replaced with your actual Brinkster UserName.
All references to "mysql_password" need to be replaced with your actual Brinkster Password.
All references to "mysql_host" need to be replaced with your actual MySQL HostName.

Please log into your account, select the web site settings, and use the MySQL database name listed there.
username is case sensitive and must be all lower case.


PHP MySQL Connection

<?php

// Connecting, selecting database

$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')

   or die('Could not connect: ' . mysql_error());

echo 'Connected successfully';

mysql_select_db('mysql_user') or die('Could not select database');

 

// Performing SQL query

$query = 'SELECT * FROM testphp';

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

 

// Printing results in HTML

echo "<table>\n";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

   echo "\t<tr>\n";

   foreach ($line as $col_value) {

       echo "\t\t<td>$col_value</td>\n";

   }

   echo "\t</tr>\n";

}

echo "</table>\n";

 

// Free resultset

mysql_free_result($result);

 

// Closing connection

mysql_close($link);

?>