Accessing your MySQL database with PHP

How do I access my MySQL database using PHP?

The following article explains how to connect to a MySQL database using PHP. A MySQL database can be accessed on our servers using all of the programming languages available on the server. Unlike Perl, PHP contains native MySQL connection support, so it is not necessary to include a module.

In order to access your MySQL database with the PHP, please follow these steps:

Type the following connection string to connect to your database:

<?php
$link = mysql_connect(\'host\', \'username\', \'password\') or die(\'Could not connect: \' . mysql_error());
mysql_select_db(\'database\') or die(\'Could not select database\');
?>

  1. host: enter the MySQL server that you are assigned to, for example, mysql1.media3.net
  2. username: enter the username provided for your database
  3. password: enter the password provided for your database
  4. database: enter the name of the MySQL database