472,337 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

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 3256
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

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

Similar topics

10
by: Alvaro G Vicario | last post by:
I need that my script retrieves data from two different databases so I use mysql_connect() to open two connections. I have only one server, user and...
2
by: Sugapablo | last post by:
I have a small test script connecting to a MySQL database. It seems to work, unless I try to use the resource link identifier returned by...
19
by: Michael | last post by:
Hi, I'm trying to do something which should be very simple - connect to the MySQL database. Here is the call, followed by the error msg. ...
7
by: avenpace | last post by:
Hi, I got error when using mysql_connect function in my php script. If i set the db host to localhost, it give me that error altough all the...
1
by: hugo | last post by:
Hello people, There is a problem is that mysql_connect() somehow caches last sessions IP and is not using the one which you put into host place....
1
by: goodmann | last post by:
Paris, Le 30 08 MMVII, Hi, I have a problem using to connect to MYSQL from one server to another server. In other words, On server A, I...
14
by: farhan | last post by:
Hi, Please divert me if this is not the right group to be posting this question. I am a Linux client trying to connect to a mysql windows...
7
by: criveraf | last post by:
Hi there, I wasn't sure where to put this question, since it deals with both PHP and MySQL. I apologize if this is not the correct forum for...
0
by: Alan Silver | last post by:
Hello, I'm a newbie at PHP and MySql, although I have wads of experience of ASP, ASP.NET, SQL Server, etc. I have just installed PHP 5.2.3 on...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.