Hi guys! need help here
Is it possible for my php page that is uploaded into one host be connected and retrieve information/data from a MySql Database which is being hosted in another host?
If yes... pls help! here the code i use to connect the database:
<?php
// This file contains the database access information. This file also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'domain_erickes');
DEFINE ('DB_PASSWORD', 'MyPassword');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'domain_makatimedicalcenter');
if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connnection.
if (!mysql_select_db (DB_NAME)) { // If it can't select the database.
// Handle the error.
my_error_handler (mysql_errno(), 'Could not select the database: ' . mysql_error());
// Print a message to the user, include the footer, and kill the script.
echo '<p><font color="red">The site is currently experiencing technical difficulties. We apologize for any inconvenience.</font></p>';
include_once ('public_html/themedicalcity/includes/footer.html');
exit();
} // End of mysql_select_db IF.
} else { // If it couldn't connect to MySQL.
// Print a message to the user, include the footer, and kill the script.
my_error_handler (mysql_errno(), 'Could not connect to the database: ' . mysql_error());
echo '<p><font color="red">The site is currently experiencing technical difficulties. We apologize for any inconvenience.</font></p>';
include_once ('public_html/website/includes/footer.html');
exit();
} // End of $dbc IF.
// Function for escaping and trimming form data.
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string (trim ($data), $dbc);
} // End of escape_data() function.?>
Please help! tnx! 🙂