<?php
/* SQL functions.php */
function connect($user$pass$host$db)
{
    
$connect = @mysql_connect($host$user$pass);
    
    if (!
$connect) throw new Exception('Failed to connect to DB');
    
    
$select = @mysql_select_db($db$connect);
    
    if (!
$select) throw new Exception('Failed to select DB');
    
    return 
$connect;
}

function 
sql_query($query$connect_id)
{
    
$result = @mysql_query($query$connect_id);
    
    if (!
$result) throw new Exception('Failed to query DB');
    
    return 
$result;
}

function 
sql_fetch_array($query_id)
{
    return @
mysql_fetch_array($query_idMYSQL_ASSOC);
}

function 
sql_close($connect_id)
{
    
$close = @mysql_close($connect_id);
    if (!
$close) throw new Exception('Failed to close DB');
}
?>