Database? Are we talking about MySQL?
Check your privilige tables; how are you connecting? Is the username you're using in the remote script granted as "username@%" or "username@localhost" ? Big difference 🙂
Again, though, are we talking about a MySQL database connection?
$conn = @mysql_connect('yourip', 'user', 'pass') or die('error connecting!<br>mysql said: ' . mysql_error());