SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    556
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Unhappy MySQL server has gone away

    Hello,

    I have made a php script which just executes 3 queries.

    1st query gets only 1 record.
    2nd query is suppose to get a max of 500 records (LIMIT 500 is used)
    3rd query is used to update 1 record.

    On 3rd query I get: MySQL server has gone away.

    Why this is happening ? What to do to fix it ?

    Thanks.

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    Are you getting any errors from either PHP or MySQL?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    556
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Are you getting any errors from either PHP or MySQL?
    The last query that is suppose to update the record fails and when i used mysql_error() to see the error i got that else there are no errors of any types and all is working fine, but if this last query does'nt works then my script also fails coz it will next time produce wrong results.

    Thanks.

  4. #4
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    Does the 3rd query work ok when executed via phpmyadmin or the mysql console?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  5. #5
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    556
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Does the 3rd query work ok when executed via phpmyadmin or the mysql console?
    Hi,

    Yes i tried it in phpmyadmin and it works absolutely fine. Its a very simple update query which is updating 2 cols with 1 where clause.

    Thanks.

  6. #6
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    echo the 3rd query that php is sending to MySQL, is there anything which stands out as not being right?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  7. #7
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    556
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    echo the 3rd query that php is sending to MySQL, is there anything which stands out as not being right?
    I already added the debug mode to it..and all queries are fine. This error message i came to see when i was debugging the script. The query is fine and i copied it when i was debugging and ran it in phpmyadmin and it executed fine. But in script it gave me that error.

    Basically the first query gets the details in 1 single record out of 2-3 records in a table (LIMIT 1 is used)

    then 2nd query gets 500 records based on the first query result and processes the information which is nothing to do with db (LIMIT 500 used)

    A while and mysql_fetch_array based loop is used to process the info.

    then 3rd query's (which is failing) job is to update the counter to the last record we got in the 2nd query (LIMIT 1 used). And this is where the error is happening.

    Example:
    first query gets us the last id number that was processed, say we get: 500

    then 2nd query is used to get records beyond 500 till next 500. So we get from 501 to 1000.

    and 3rd query's job is to update the id number of last processed record in the db i.e set last id number = 1000.

    Thats it. Simple but failing at the end. What i am done now is put the lines to re-connect to the database.. i hope this will resolve the issue but i wont know till tommorow.

    Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •