Connect to database using wordpress wp-config file

Using the defines the user sets in wp-config:

mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

EDIT:
Since your script is outside the WordPress environment, what you want to do is initiate it before using the defines in wp-config.

require_once('./path/to/the/wp-config.php');
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

Leave a Comment