You can always include the wp config file for the db name, etc...
// Include config, you'll need to know the path
include_once('/path/to/wordpress/wp-config.php');
// Check if it's picked up the constants, if not then something isn't right
if(!defined('DB_USER') || !defined('DB_PASSWORD') || !defined('DB_HOST')) die('File was not included');
// Do mysql stuff, but now using constants from config file
..it'll also include wp-settings for you (it's a require at the bottom of the config).. This will include a bunch of extra stuff that you can utilise because the settings file itself includes several files to.
If you would prefer to stick with your above method (which is proberly more efficient) i'll happily help where needed. Perhaps if you could give some examples of what is being output by your above code if anything?
NOTE: I'm not sure posting your database user and password information is a good idea. If that's current you'd be wise to go change that straight away.
MODS: Could you asterisk the info until the poster has changed his information?