Nguyen Duc Thuan's Homepage » PHP »

“Lost connection to MySQL server during query”

If you don’t perform any query after creating connection to MySQL server, it may cause this problem.

The simple solution is to use mysql_ping PHP function to check the connection, if it’s lost, attempt to recreate it.

if (!mysql_ping($linkId)) {
    mysql_close($linkId);
    mysql_connect('host', 'username', 'password');
    mysql_select_db('db_name');
    // do your normal queries here
}

Related Posts

No related posts.

Share and enjoy:
Design BumpDeliciousDiggFacebookDesign FloatMixxRedditStumbleUponTechnoratiTwitter

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>