2

I am working on client/server side in android. And create a php file which contains only these lines of code:

mysql_connect("192.184.10.45");  //line#3
mysql_select_db("Test_Data");
$sql=mysql_query("select * from registeration ");
mysql_close();

When I run this on browser then this give me these messages:

Warning: mysql_connect() [function.mysql-connect]: Host ' ' is not allowed to connect to this MySQL server in C:\xampp\htdocs\Project1\server.php on line 3

nickhar
  • 19,981
  • 12
  • 60
  • 73
User42590
  • 2,473
  • 12
  • 44
  • 85
  • 3
    Seems pretty self-explanatory - check that your MySQL server allows remote access from your webserver box – Mark Baker Apr 09 '13 at 12:05
  • 1
    You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). – Quentin Apr 09 '13 at 12:06

1 Answers1

2

pass username and password also here

mysql_connect("192.184.10.45","username","password"); //line#3

And stop using mysql_* functions they are deprecating, use instead Mysqli OR PDO.

Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
  • in username i gave my system username and in pass i gave my system pass but its not working still – User42590 Apr 09 '13 at 12:16
  • @User42590 Is `192.184.10.45` your current system? If yes then use `localhost`. If not then use that system's `mysql's` username and password. – Yogesh Suthar Apr 09 '13 at 12:17
  • i am new in mysql connectivity so don't know much about it so i don't know what will be the username and pass of mysql. So how to know it – User42590 Apr 09 '13 at 12:22
  • @User42590 Is `192.184.10.45` your current system? – Yogesh Suthar Apr 09 '13 at 12:26
  • 192.184.10.45 is system's ip and name of my computer is "User_1" so when error occurs it prints :Warning: mysql_connect() [function.mysql-connect]: Host 'User_1' is not allowed to connect to this MySQL server in C:\xampp\htdocs\Project1\server.php on line 3 – User42590 Apr 09 '13 at 12:28
  • @User42590 I knows 192.184.10.45 is system's ip. But is it your current system or remote system? – Yogesh Suthar Apr 09 '13 at 12:29
  • Use username as `root` and password as `root` OR `empty password`. – Yogesh Suthar Apr 09 '13 at 12:33