469,917 Members | 1,473 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

newbie: mysql_connect problem

7
Help!!!! i am newbie to php, i was trying to establish the connection to another machine (solaris) so that i can retrieve data from the database stored inside there using my own PC.

for your information, i am using apache 1.3.27 as my web server, php4 and mysql as i try to build an database with a web portal.

the following is the scripts that i have written:

[PHP]
<?php
$connection = mysql_connect ("202.185.72.62:80","root","") or die ("connection failed");
echo ("connection made!");
mysql_close($connection);
?>
[/PHP]

i have also try to use default port number to connect (3306) but it still cannot work!

below is the error message that i got:

Warning: Lost connection to MySQL server during query in c:\phpdev\www\try_connection.php on line 2

Warning: MySQL Connection Failed: Lost connection to MySQL server during query in c:\phpdev\www\try_connection.php on line 2

Fatal error: Maximum execution time of 30 seconds exceeded in c:\phpdev\www\try_connection.php on line 2
please help me as i am totally run out of idea! thanks..
Apr 15 '07 #1
5 3190
Hi
I am not very sure, I too had the same problems a while ago. Anyways, try increaing the time out value in your php.ini file to a very large value. Increase it to say 10000 seconds.. Also use the port number 3306. Check your firewall settings. Open a port for MySql if there s not one already. Or best, time being disable firewall just to ensure its not your firewall thats not lettin u to connect.
Regards

Help!!!! i am newbie to php, i was trying to establish the connection to another machine (solaris) so that i can retrieve data from the database stored inside there using my own PC.

for your information, i am using apache 1.3.27 as my web server, php4 and mysql as i try to build an database with a web portal.

the following is the scripts that i have written:

[PHP]
<?php
$connection = mysql_connect ("202.185.72.62:80","root","") or die ("connection failed");
echo ("connection made!");
mysql_close($connection);
?>
[/PHP]

i have also try to use default port number to connect (3306) but it still cannot work!

below is the error message that i got:



please help me as i am totally run out of idea! thanks..
Apr 15 '07 #2
yoyoz
7
Hi
I am not very sure, I too had the same problems a while ago. Anyways, try increaing the time out value in your php.ini file to a very large value. Increase it to say 10000 seconds.. Also use the port number 3306. Check your firewall settings. Open a port for MySql if there s not one already. Or best, time being disable firewall just to ensure its not your firewall thats not lettin u to connect.
Regards
I am not sure what you mean by open a port for MySQL, can you describe it in more details. As you were mentioned, you were having the same problem, what is the solution for you at last? I have disable the firewall in my PC, maybe i will try to change the time out value, but shouldn't it be connected very fast if there is no connection problem? thanks for your reply..
Apr 16 '07 #3
Atli
5,058 Expert 4TB
Hi.

Are you sure your MySQL is set to accept remote connection?

Btw. it would be much easyer to diagnose the problem if you'd print the error message when your connection fails.

You can do that like this
[PHP]
mysql_connect($q, $l) or die(mysql_error());
[/PHP]
Apr 16 '07 #4
yoyoz
7
Hi.

Are you sure your MySQL is set to accept remote connection?

Btw. it would be much easyer to diagnose the problem if you'd print the error message when your connection fails.

You can do that like this
[PHP]
mysql_connect($q, $l) or die(mysql_error());
[/PHP]
Hi,
how to set MySQL to the accept remote connection? Below is the MySQL environment setting in the DB server, in this case the Solaris machine that i've mentioned earlier in the post. Is the setting correct?

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 4.0.26
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE -I/usr/local/mysql/include
MYSQL_LIBS -L/usr/local/mysql/lib -lmysqlclient

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
And below is the error message that i got when i am trying to the DB server from my own PC.
Warning: mysql_connect(): Can't connect to MySQL server on '202.185.72.62' (10054) in c:\program files\easyphp1-7\www\try_solaris.php on line 2
Can't connect to MySQL server on '202.185.72.62' (10054)
Thanks...
Apr 17 '07 #5
Atli
5,058 Expert 4TB
I'm not sure how this would work on Solaris machines, but I do know that mysql will not allow remote access to the root account by default, have you tried creating another account?
By crateing a user without specifying an IP address MySQL should accept remote connections on that user from anybody.
Apr 18 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Alvaro G Vicario | last post: by
19 posts views Thread by Michael | last post: by
7 posts views Thread by avenpace | last post: by
1 post views Thread by goodmann | last post: by
14 posts views Thread by farhan | last post: by
reply views Thread by Alan Silver | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.