I connect php application to mysql from two different files from one file it

is connecting and from other file it gives me following error message.

Connection Failed because: Access denied for user 'ODBC'@'localhost' (using password: NO)

even i am using same connection string in both files but still problem exist!!

like in this way

$dbh=mysql_connect ('localhost','newuser','mypass');


PHP Code:
$dbh=mysql_connect ('localhost','newuser','mypass');
mysql_select_db ("twmweb");

$result=mysql_query("select * from inventory");
$EOF=mysql_num_rows($result); 
above php code working

but following sample function gives above error

PHP Code:
function connect() 
{
    global 
$db_name;
    
$connection mysql_connect ('localhost','newuser','mypass');
     or  die(
"Connection Failed because: " mysql_error() );

    
$db mysql_select_db("twmweb" $connection) or die("Invalid database name " );
    return 
$connection;

i required help as soon as possible