Location: PHPKode > projects > Helpdesk Solutions > helpdesk/include/database.php
<?

$sys_dbhost='localhost';
$sys_dbuser='username';
$sys_dbpasswd='password';
$sys_dbname='dbname';

$conn = mysql_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd) or die(mysql_errno()."1: ".mysql_error());
$db = mysql_select_db($sys_dbname,$conn) or die(mysql_errno().":2 ".mysql_error());


function db_connect() {
	global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$conn;
	$conn = mysql_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd) or die("Couldn't connect.");
	//$db = mysql_select_db($sys_dbname,$conn) or die(mysql_errno().": ".mysql_error());
	if (!$conn) {
		echo mysql_error();
	}
	return $conn;
}

//This one works
function db_query2($sql,$conn) {
	return mysql_query($sql,$conn);
}

function db_query($qstring,$print=0) {
	global $sys_dbname;
	
	//db_connect();
	return @mysql($sys_dbname,$qstring);
	//return mysql_query($qstring,$conn);
	//return true;
}

function db_numrows($qhandle) {
	// return only if qhandle exists, otherwise 0
	if ($qhandle) {
		return @mysql_numrows($qhandle);
	} else {
		return 0;
	}
}

function db_result($qhandle,$row,$field) {
	return @mysql_result($qhandle,$row,$field);
}

function db_numfields($lhandle) {
	return @mysql_numfields($lhandle);
}

function db_fieldname($lhandle,$fnumber) {
           return @mysql_fieldname($lhandle,$fnumber);
}

function db_affected_rows($qhandle) {
	return @mysql_affected_rows();
}
	
function db_fetch_array($qhandle) {
	return @mysql_fetch_array($qhandle);
}
	
function db_insertid($qhandle) {
	return @mysql_insert_id($qhandle);
}

function db_error() {
	return "\n\n<P><B>"hide@address.com()."</B><P>\n\n";
}



?>
Return current item: Helpdesk Solutions