HOME       >>       Programming

Lost Connection To Mysql ,..., System Error: 111 In


rockarolla

While I was trying to connect to my database or even create one using PhP mySQL I was given the followoing error:Lost connection to MySQL server at 'reading initial communication packet', system error: 111 inHas somebody encontered a similar report? I have my database created using the cpanel together with a user name and password.I wonder if it is a server issue? What can you do if you have not access to the configuration files?


yordan

If you can access your database through cpanel and PHPMyAdmin, it's not a server issue. So, the issue is inside your php program.


rockarolla

I don't think so. Here is my code. Its a very simple code just to see if I can ever establish a connection with my database:

function open_connection() { $host='localhost:3307'; $user='any'; $db='my_db'; $password='my_pass'; $conn=mysql_connect($host,$user,$password); mysql_create_db ($db,$conn); mysql_select_db($db); return $conn;}

If I call this function within my file I get the error:

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in

I've looked about several forums and I didn't get any concern to my code.

Also I tried using mysql_pconnect() as someone suggested that the problem maybe dropping connection, but it didn't work as well.

I don't have any rights to configure neither php nor mysql. So I guess the provider doesn't want anyone to connect to their database...

On the same host I cannot use code like this:

function add_hits(){ $opFile = fopen ("counter.txt", "r"); $handle = fread ($opFile, filesize ("counter.txt")); fclose ($opFile); . . .

so I think at the end that this is a server issue.

TavoxPeru

I don't think so. Here is my code. Its a very simple code just to see if I can ever establish a connection with my database:

function open_connection() { $host='localhost:3307'; $user='any'; $db='my_db'; $password='my_pass'; $conn=mysql_connect($host,$user,$password); mysql_create_db ($db,$conn); mysql_select_db($db); return $conn;}

If I call this function within my file I get the error:

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in
As far as i know you use the port 3306 when you want to connect to a MySql host, not to the port that you specify, in this case 3307, also, you don't need to specify this on your connection scripts. So, change it to 3306 or delete from your code.

Also, add to your code the mysql_error() function to check when you lost the connection and verify that in first case you get connected to the server:
function open_connection() { $host='localhost'; $user='any'; $db='my_db'; $password='my_pass'; $conn=mysql_connect($host,$user,$password); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_create_db ($db,$conn) or die('Could not connect: ' . mysql_error()); mysql_select_db($db); return $conn;}

Another problem is that according to the PHP online manual the mysql_create_db() function is obsolete and recommends to use the mysql_query() function instead.

Best regards,


VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.