1
votes

I have a php file to fetch data from a server

When I try to execute it, I get a message saying:-

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/-/-/public_html/GetData.php on line 3

And line 3 is

              $con = mysql_connect("cs.neiu.edu","myusername","mypassword");

Also I've tried by giving the hostname as localhost,but its not working.

3

3 Answers

1
votes

You need to configure binding address bind-address in my.cnf and grand access to the database eg. GRANT ALL ON foo.* TO bar@'162.54.10.20' IDENTIFIED BY 'PASSWORD';

1
votes

That error means connection refused. I am in the same class that you are and obviously I am using the same server, and I would guess that you are entering the wrong password. It may not be the same password that you connect to the server with if you changed your password from what was given in class. I use the following and it works fine....

<?php
  $con = mysql_connect('localhost','username','password');
  if (!$con)
  {
    die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("databaseName", $con);
  ..
  ..
  ..
  mysql_close($con);
?>
0
votes

Actually i realized that my password was wrong.