Hello all,
I have come across a wierd problem while trying to connect to a remote database.
Currently, my PHP scripts are located on a shared hosting server (Siteground). My remote MySQL database is located on another shared hosting server (Hurricane Electric).
When trying to execute the connection via mysql_connect, the server will attempt to establish a connection until the request times out, at that point causing the script to halt. I have also tried mysqli to connect just for kicks, also resulting in a timeout. To avoid confusion, I am trying to access my database on another server, while having my scripts on Siteground's web server the remote database, not the other way around
The mysterious part of this is that when I run my connection script on my local development server, I can connect to my remote database successfully.
I have this strange feeling that Siteground may be blocking TCP/UDP port 3306 for my mysql_connect to my other database server. Can anyone verify this?
Any suggestions you can throw at me is much appreciated! :D
I have come across a wierd problem while trying to connect to a remote database.
Currently, my PHP scripts are located on a shared hosting server (Siteground). My remote MySQL database is located on another shared hosting server (Hurricane Electric).
When trying to execute the connection via mysql_connect, the server will attempt to establish a connection until the request times out, at that point causing the script to halt. I have also tried mysqli to connect just for kicks, also resulting in a timeout. To avoid confusion, I am trying to access my database on another server, while having my scripts on Siteground's web server the remote database, not the other way around
The mysterious part of this is that when I run my connection script on my local development server, I can connect to my remote database successfully.
I have this strange feeling that Siteground may be blocking TCP/UDP port 3306 for my mysql_connect to my other database server. Can anyone verify this?
Any suggestions you can throw at me is much appreciated! :D
PHP:
class DB {
private static $link;
public function __construct() {
if ($handle = mysql_connect(DB_HOST, DB_USER, DB_PASS)) {
mysql_select_db(DB_NAME);
self::$link = $handle;
}
/*
if ($handle = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME)) {
self::$link = $handle;
}
*/
else {
throw new Exception("Failed to connect to DB: " . mysql_error() . "\n");
}
}
public static function getDCon() {
if (!is_object(self::$link)) {
self::$link = new DB();
}
return self::$link;
}
// some code...
}