473,569 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

newbie: mysql_connect problem

7 New Member
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($co nnection);
?>
[/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\t ry_connection.p hp on line 2

Warning: MySQL Connection Failed: Lost connection to MySQL server during query in c:\phpdev\www\t ry_connection.p hp on line 2

Fatal error: Maximum execution time of 30 seconds exceeded in c:\phpdev\www\t ry_connection.p hp on line 2
please help me as i am totally run out of idea! thanks..
Apr 15 '07 #1
5 3321
cyberking
84 New Member
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($co nnection);
?>
[/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 New Member
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 Recognized Expert Expert
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 New Member
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_TY PE 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_per sistent On On
mysql.connect_t imeout 60 60
mysql.default_h ost no value no value
mysql.default_p assword no value no value
mysql.default_p ort no value no value
mysql.default_s ocket no value no value
mysql.default_u ser no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persi stent Unlimited Unlimited
mysql.trace_mod e 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_solar is.php on line 2
Can't connect to MySQL server on '202.185.72.62' (10054)
Thanks...
Apr 17 '07 #5
Atli
5,058 Recognized Expert Expert
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
5098
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 password, just two different databases. Simplified, it'd be: $con1=mysql_connect($server, $user, $pass); mysql_select_db($database1, $con1); $res1=mysql_query($sql1, $con1); ...
2
2828
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 mysql_connect(); This works and returns all the rows in the table: <?php include("../config.php"); $dbi = mysql_connect($dbhost,$dbuname,$dbpass);
19
8094
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. $conn = mysql_connect("localhost", "root", ""); Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/buildhw.php on line 13
7
5406
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 user and password that I wrote is true(I can login using that username/passwd using mysql console), but when I change the db host into 127.0.0.1 mysql_connect will work. Beside of that I can't make my...
1
4353
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. Has anyone made mysql_connect() from php to multiple SQL servers so that script tries to connect to resolved IPs until it finds one that works? I have set up DNS so that on request...
1
1911
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 have my PHP files, and on server B, I have MySQL installed.
14
2109
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 server via php, upon hitting the mysql_connect line in my php script, it simply stops executing. In other words anything or'ed with it, like echo does not end up in the html source. I'm not entirely...
7
2841
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 this. I am working with a simple PHP application using MySQL at the data layer. This is on a Windows XP machine, using IIS 6.0, MySQL 5.0, PHP 5. The problem I am having is that a call to...
0
1125
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 a server (Windows Server 2003), as well as MySql 5.0.45. Both of these work fine independently, but I can't get PHP to connect to MySql. The first (and probably most basic) problem is that when I...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.