how to work with a remote mysql database ??

I got two servers: "www.grupossc.com" with linux and "www.pvtcloudlab.com" with windows

in pvtcloudlab.com the page load his own database but also the mysql databse located in "www.grupossc.com", most of the time the system works without problems, but from time to time the page show you this error:
Warning: mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Inetpub\vhosts\pvtcloudlab.com\httpdocs\users\Connections\dbnotes1.php on line 16

Fatal error: in C:\Inetpub\vhosts\pvtcloudlab.com\httpdocs\users\Connections\dbnotes1.php on line 16

Open in new window


that error reffers to this line:
$dbnotes1 = mysql_connect($hostname1, $username1, $password1) or trigger_error(mysql_error(),E_USER_ERROR);
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_dbnotes = "localhost";
$database_dbnotes = "xxxxxx";
$username_dbnotes = "xxxxxx";
$password_dbnotes = "xxxxxx";
$dbnotes = mysql_connect($hostname_dbnotes, $username_dbnotes, $password_dbnotes) or trigger_error(mysql_error(),E_USER_ERROR); 


$hostname1 = "www.grupossc.com";
$database1 = "xxxxxx";
$username1 = "xxxxxx";
$password1 = "xxxxxx";
$dbnotes1 = mysql_connect($hostname1, $username1, $password1) or trigger_error(mysql_error(),E_USER_ERROR);
?>

Open in new window


Anyone know why this error happend but just sometimes??? and it is  a way to solve it??????
altariamx2003Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Are you sure the server  with Linux works correctly...have checked if this is an network connectivity issue....is logging for MySQL working?
0
altariamx2003Author Commented:
hi john thx for your time.

As far as i know all work ok, this problems sometimes emerges when i try to connect the base in pvtcloudlab.com from grupossc.com
0
John TsioumprisSoftware & Systems EngineerCommented:
The "sometimes" points to something between pvtcloudlab and grupossc...i don't think its MySQL's fault...to ensure that there are several stress test floating on the Internet...
0
Ray PaseurCommented:
There are two issues here.  First, the timeout.  It almost does not matter what might be causing this - internet traffic, server load, etc.  This should not be handled as a fatal error.  Your script should sleep() for one second and retry.  Downgrade the error level to E_USER_WARNING, suppress error display, and just log the error.  Maybe tweet or email to the server admin at the balky server.  HTTP(S) delays are common, and treating them as fatal errors is overkill.  I would retry up to 10 times, for starters.

Second, you're obviously using an out-of-date script.  The MySQL extension is not supported any more, and it has been removed from all current levels of PHP, so it's time to upgrade.  You should be up to PHP 7.1 and you need to get off MySQL.  Instead of MySQL choose one of the extensions that still exists: MySQLi or PDO.  Here is how and why that is necessary:
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

A substantial benefit of upgrading your PHP will be visible when you start to compare performance.  PHP 7+ is often twice as fast as the old versions!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.