Jump to content

trying to connect to mysql databse in another machine


suyesh.amatya

Recommended Posts

I have a php script in my machine and via it I want to access the database in the other machine with IP 192.168.0.104.

The code is:

 

        mysql_connect("192.168.0.104","root","");

  mysql_select_db("dbtest");

  $sql="select * from dbtest";

  $result=mysql_query($sql);

  while($data=mysql_fetch_array($result)){

      echo $data['name'];

  }

but i am not being able to do this.Need help..

try adding error checking to your script

  mysql_connect("192.168.0.104","root","") or die(mysql_error());

  mysql_select_db("dbtest") or die(mysql_error());

  $sql="select * from dbtest";

  $result=mysql_query($sql) or die(mysql_error());

  while($data=mysql_fetch_array($result)){

      echo $data['name'];

  }

 

Scott.

Are you trying to connect to local server in your office.

If i am right.Then check for the permission issues.

Or store your ip in the server mysql user table with root priv.

If i am getting you correctly.

I am also using the same way.

Accessing my database from local server within a network.i put my ip there in the user table with root priv.

An assign my computer static ip.Even that i am using two connections with diff ips.when need to connect to server, i just changed the connection.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.