php script with MySQL server has gone away

Thread Solved

Join Date: Sep 2009
Posts: 523
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro

php script with MySQL server has gone away

 
0
  #1
34 Days Ago
I have an API parsing script, which inserts into the db more than 40,000 rows.and maybe due large numbers of queries getting fired continuously, after some specific time the script throws "MySQL server has gone away" error.
I know the reason behind this error can be closed connection or any other privileges on the mysql server.
How should I deal with this error , so that i can execute the script completely.
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 823
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 135
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
1
  #2
34 Days Ago
If you really need to do this this way, then creating a msqli_multi_query could help. That way the server gets all queries at once, and does not need to handle each query separately.

http://php.net/manual/en/mysqli.multi-query.php
Last edited by pritaeas; 34 Days Ago at 11:22 am.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 15
Reputation: Namibnat is an unknown quantity at this point 
Solved Threads: 1
Namibnat Namibnat is offline Offline
Newbie Poster

Thanks

 
0
  #3
34 Days Ago
Originally Posted by pritaeas View Post
If you really need to do this this way, then creating a msqli_multi_query could help. That way the server gets all queries at once, and does not need to handle each query separately.

http://php.net/manual/en/mysqli.multi-query.php

Thank you. I am not sure that I need to do it that way? I am really a beginner with this stuff and just playing around creating a blog for myself. I have got it all working in a really simple way for the time being.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 523
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro
 
0
  #4
34 Days Ago
Originally Posted by pritaeas View Post
If you really need to do this this way, then creating a msqli_multi_query could help. That way the server gets all queries at once, and does not need to handle each query separately.

http://php.net/manual/en/mysqli.multi-query.php
thanks, but msqli_multi_query won't be suitable in this case.Because the code is checking in the db simultaneously to avoid inserting any duplicates, so i will need to insert one by one only.Can we do anything else than this
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 523
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro
 
0
  #5
34 Days Ago
hey pritaeas, i solved the problem on my own, doing it other way.
now i am storing all the ids to some text file and the other script will fetch this ids from the line number its been told in the url,like script_name.php?limit=100 and so on.
Now i need to run the second script 10 times if there are 1000 ids in file created by first cron, since the bound or limit in second script is set as 100.
and doing the same logic in that script, i hope it will work for long term if set as a cron and after some duration.
But now new problem arises how to tackle this situation as a cron.
This is totally new topic from the subject of this thread, so i have created another thread dynamic cron , please have a look at it.
Thanks for your help
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Reply


This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC