Codice PHP:
/*
Opens a MySQL database and stores the handle to $db passed by reference.
Returns 0 on success or an error code:
1 unable to login
2 unable to open database
*/
function mysql_opendb(&$db$host$username$password$dbname)
{
    if(!
$db mysql_connect($host$username$password))
    {
        return 
1;
    }
    
    if(!
mysql_select_db($dbname))
    {
        return 
2;
    }
    
    return 
0;