<?php

/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'webgrids_new-richie');
define('DB_PASSWORD', 'Izuchukwu1');
define('DB_NAME', 'webgrids_new-richie');

/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

function dbQuery($sql)
{
        global $link;
	$result = mysqli_query($link, $sql) or die(mysqli_connect_error());

	return $result;
}

function dbAffectedRows()
{
	global $link;

	return mysqli_affected_rows($link);
}

function dbFetchArray($result, $resultType = MYSQL_NUM) {
	return mysqli_fetch_array($result, $resultType);
}

function dbFetchAssoc($result)
{
	return mysqli_fetch_assoc($result);
}

function dbFetchRow($result)
{
	return mysqli_fetch_row($result);
}

function dbNumRows($result)
{
	return mysqli_num_rows($result);
}

?>
