Lost connection to MySQL server during query

Codes here !

Moderators: egami, macek, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Oct 11, 2012 8:30 am

I think you're actually getting a couple of different errors (that are requiring different fixes) but would have to see the offending queries to be sure. Here are a few ways to avoid sql errors, and correctly debug them when you do get them.

1) make sure you use mysqli_real_escape_string or the mysql_ equivalent if you're using mysql_ for each of your variables.

2) if you build your query in parts, make sure you have a trailing space between sections, so it doesn't turn into "SELECT fieldFROM tableWHERE condition"

3) when you get an error, verify your query before you try to rewrite it etc. usually i'll just add

Code: Select all

die($query);
right after the query string is built, before it's attempted. A lot of times your problem will be obvious as soon as you see the parsed query.

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Wed Oct 17, 2012 7:29 am

How long does it take the query to run from the console?

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Fri Oct 19, 2012 10:14 pm

Check those warnings.

Check your application and db server logs.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest