I have an online database and I need to connect my local for some data synchronization purposes. so what I did was I setup an Remote MYSQL to the host using my local IP address. Now, have this line of code to connect to both local and online database:
$connection = mysql_connect('localhost', 'root');
if(!$connection) {
die ("Database connection failed: " . mysql_error());
}
$db_select = mysql_select_db('db_name', $connection);
if(!$db_select) {
die("Database connection failed: ". mysql_error());
}
/* connection to online database */
$connection_online = mysql_connect(localhost, DB_USER_ONLINE, DB_PASS_ONLINE);
if(!$connection_online) {
die ("Database connection failed: " . mysql_error());
}
$db_select = mysql_select_db(DB_NAME_ONLINE, $connection_online);
if(!$db_select) {
die("Database connection failed: ". mysql_error());
}
when I run this code I got this error: Warning: mysql_connect(): Access denied for user 'umalert_local'@'localhost' (using password: YES) in E:\xampp\htdocs\capstoneProjects\server_includes\connection.php on line 18 Database connection failed:
Am I doing a right thing? Is possible to connect to both local and online database in the same time? Thank you.