Database Status

Database Status
MySQL
Oracle

Connecting to MySQL databases using PHP

The following example show how to connect to the MySQL database using PHP. If the connection fails, the error will be printed out.

$mysql_server = "mysql.comp.polyu.edu.hk";
$mysql_user = "{your student id}";
$mysql_password = "{your mysql database password}";
$mysql_db = "{your student id}";

$conn = mysqli_connect($mysql_server, $mysql_user,$mysql_password,$mysql_db);

// Check connection
if (mysqli_connect_errno())
	echo "Failed to connect to MySQL: " . mysqli_connect_error();

Connecting to Oracle databases using PHP

The following example show how to connect to the Oracle database using PHP. If the connection fails, the error will be printed out.

$oci_user = "{your student id}";
$oci_password = "{your mysql database password}";
$oci_database = "//studora.comp.polyu.edu.hk:1521/dbms";

$conn = oci_connect($oci_user, $oci_password, $oci_database);

//Check Connection
if (!$conn) {
	$e = oci_error();
	trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}