suyesh.amatya Posted July 22, 2008 Share Posted July 22, 2008 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.. Link to comment https://forums.phpfreaks.com/topic/115968-trying-to-connect-to-mysql-databse-in-another-machine/ Share on other sites More sharing options...
ratcateme Posted July 22, 2008 Share Posted July 22, 2008 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. Link to comment https://forums.phpfreaks.com/topic/115968-trying-to-connect-to-mysql-databse-in-another-machine/#findComment-596223 Share on other sites More sharing options...
suyesh.amatya Posted July 22, 2008 Author Share Posted July 22, 2008 the error message I get is: Host 'SUYESH' is not allowed to connect to this MySQL server Link to comment https://forums.phpfreaks.com/topic/115968-trying-to-connect-to-mysql-databse-in-another-machine/#findComment-596232 Share on other sites More sharing options...
mmarif4u Posted July 22, 2008 Share Posted July 22, 2008 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. Link to comment https://forums.phpfreaks.com/topic/115968-trying-to-connect-to-mysql-databse-in-another-machine/#findComment-596234 Share on other sites More sharing options...
rameshfaj Posted July 22, 2008 Share Posted July 22, 2008 Have the database server in the remote machine given access privilege to the other ips? Link to comment https://forums.phpfreaks.com/topic/115968-trying-to-connect-to-mysql-databse-in-another-machine/#findComment-596239 Share on other sites More sharing options...
samshel Posted July 22, 2008 Share Posted July 22, 2008 you can add your IP to the host table with correct privileges. adding an entry in the host table with Host as "%" will give rights to any machine to connect to your mysql server, but that is not advised, Link to comment https://forums.phpfreaks.com/topic/115968-trying-to-connect-to-mysql-databse-in-another-machine/#findComment-596240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.