PHP Warning: mysql_connect(): Connection timed
#1

[13-Jun-2016 11:34:49 America/Chicago] PHP Warning: mysql_connect(): Connection timed out in /home/firstgam/public_html/cp/global/class/SQL.php on line 12


Код:
<?php
 
 
 
 
// Linux Box
DEFINE('HOST', '192.99.11.136');
DEFINE('USRNM', 'f1874_test');
DEFINE('PSWD', '22665139');
DEFINE('DBNM', 'f1874_test');
 
$link = mysql_connect('192.99.11.136', 'f1874_test', '');
if (!$link) {
   die('cannot connect : ' . mysql_error());
}
echo 'Connected';
 
$db_selected = mysql_select_db('f1874_test', $link);
if (!$db_selected) {
   die ('cant select the database  : ' . mysql_error());
}
 
 
 
?>
Reply
#2

Quote:
Originally Posted by Iverso
Посмотреть сообщение
[13-Jun-2016 11:34:49 America/Chicago] PHP Warning: mysql_connect(): Connection timed out in /home/firstgam/public_html/cp/global/class/SQL.php on line 12


Код:
<?php
 
 
 
 
// Linux Box
DEFINE('HOST', '192.99.11.136');
DEFINE('USRNM', 'f1874_test');
DEFINE('PSWD', '22665139');
DEFINE('DBNM', 'f1874_test');
 
$link = mysql_connect('192.99.11.136', 'f1874_test', '');
if (!$link) {
   die('cannot connect : ' . mysql_error());
}
echo 'Connected';
 
$db_selected = mysql_select_db('f1874_test', $link);
if (!$db_selected) {
   die ('cant select the database  : ' . mysql_error());
}
 
 
 
?>
change
Quote:

DEFINE('HOST', '192.99.11.136');

To
Quote:

DEFINE('HOST', 'localhost');

and
Quote:

$link = mysql_connect('192.99.11.136', 'f1874_test', '');

To
Quote:

$link = mysql_connect('localhost', 'f1874_test', '');

I've got that problem just a week ago
Reply
#3

not working
Reply
#4

i got same your problem when i have a linux host
i don't know why MySQL hosted in a linux can be connected only with localhost
if you want to make it working search for a windows hosting or search for a host support MySQL + Web Hosting

For me, i sloved this problem by registering in this website mywindowshosting.com
this website giving free web hosting windows for 2 months. when you register create a database and save the info of host
Reply
#5

mysql is no longer supported, use mysqli
And it is possible that the connection is closed from the outside
Quote:

DEFINE('HOST', '192.99.11.136');
DEFINE('USRNM', 'f1874_test');
DEFINE('PSWD', '22665139');
DEFINE('DBNM', 'f1874_test');
DEFINE('PORT', '');
$link = new mysqli(HOST, USRNM, PSWD, DBNM, PORT);
if ($link->connect_error) {
die('Error Connection (' . $link->connect_errno . ') '
. $link->connect_error);
}
$example = $link->query("SELECT * FROM `users` WHERE `userid` = '1' LIMIT 0, 1");
$result = $example->fetch_assoc();
echo $result['username'];
$link->close();

Reply
#6

The FRAG MySQL server does not allow remote connections. Consider using a different MySQL host.
Reply
#7

Quote:
Originally Posted by Slawiii
Посмотреть сообщение
i got same your problem when i have a linux host
i don't know why MySQL hosted in a linux can be connected only with localhost
if you want to make it working search for a windows hosting or search for a host support MySQL + Web Hosting

For me, i sloved this problem by registering in this website mywindowshosting.com
this website giving free web hosting windows for 2 months. when you register create a database and save the info of host
This has nothing to do with the OS. Server providers and VPS users alike usually block remote connections from a security point of view. Only the essential ports are opened and the rest are securely closed. Admittedly, if you have a VPS you can whitelist certain IP addresses/ranges, while implicitly blacklisting all the rest.

And a word of caution: the "mysql" PHP extension is deprecated and has been completely removed from PHP 7 onwards. Use PDO or mysqli instead.
Reply
#8

Quote:
Originally Posted by Crazy_Str
Посмотреть сообщение
mysql is no longer supported, use mysqli
And it is possible that the connection is closed from the outside
PHP Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /home/firstgam/public_html/cp/global/class/SQL.php on line 7
Reply
#9

Quote:
Originally Posted by SkillNasr
Посмотреть сообщение
change

To

and

To


I've got that problem just a week ago
Why the localhost?

Manya.
Reply
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
This has nothing to do with the OS. Server providers and VPS users alike usually block remote connections from a security point of view. Only the essential ports are opened and the rest are securely closed. Admittedly, if you have a VPS you can whitelist certain IP addresses/ranges, while implicitly blacklisting all the rest.

And a word of caution: the "mysql" PHP extension is deprecated and has been completely removed from PHP 7 onwards. Use PDO or mysqli instead.
I think it from the OS

so thanks bro now i am understanding
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)