Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,170 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,301 people online right now. Registration is fast and FREE... Join Now!




accessing mysqldb in my lan

 
Reply to this topicStart new topic

accessing mysqldb in my lan

kummu4help
31 Aug, 2008 - 08:54 PM
Post #1

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
Hi all,

i have a small lan in my office with 3 systems connected. Each system has it's own mysql database. But i want to access database tables in other system.
I have the following simple php code to access mysql database that resides in my other system that connected to lan.
CODE

mysql_connect("192.168.0.7","root","password") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

$query="show tables";
$result=mysql_query($query);

while($row=mysql_fetch_assoc($result))
{
    print $row['tables_in_test'];
    print "<br>";
}


but i'm getting following error

CODE

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '192.168.0.7' (10060) in C:\Inetpub\wwwroot\filewar\first.php on line 150
Can't connect to MySQL server on '192.168.0.7' (10060)PHP Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '192.168.0.7' (10060) in C:\Inetpub\wwwroot\filewar\first.php on line 150


i don't know y i'm getting this error can any one help me out this

This post has been edited by kummu4help: 31 Aug, 2008 - 10:17 PM
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Accessing Mysqldb In My Lan
31 Aug, 2008 - 09:00 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,166



Thanked: 78 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
I don't have access to my code right now, but the dash h option in mysql will allow you to provide a host. This is what I use to connect from other servers to the mysql database.
User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Accessing Mysqldb In My Lan
31 Aug, 2008 - 09:10 PM
Post #3

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
No2pencil,
Thanks for quick reply but i didn't find any thing like dash h in php manual related to mysql_connect() function

can u give any example code using that pls..
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Accessing Mysqldb In My Lan
31 Aug, 2008 - 09:19 PM
Post #4

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,166



Thanked: 78 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
When I'm working on the command line, & I want to look up something :

mysql -h (mysql_server) -p

After a quick glance at php.net, can you verify that the above works from a remote machine? That will assure that port 3306 is listening on the mysql server.
User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Accessing Mysqldb In My Lan
31 Aug, 2008 - 09:30 PM
Post #5

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
Thanks,
but it's not working no2pencil
is there any other way of doing it;;
User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Accessing Mysqldb In My Lan
31 Aug, 2008 - 09:37 PM
Post #6

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
Hi ,

actually i forgot to mention that i am working on iis server.
so is there anything i have to configure with respect to iis.
i'm using windows xp and php5.2.0 and mysql5.0

the following r my 3 systems(in lan) ip addresses
192.168.0.5 (host name:rambo)
192.168.0.6 (host name:jackie)
192.168.0.7 (host name:jetli)

currently i'm working on 192.168.0.6 and i want to connect to mysql in 192.168.0.7
thanks for any help

This post has been edited by kummu4help: 31 Aug, 2008 - 11:44 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:04AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month