Anidazen Posted January 27, 2007 Share Posted January 27, 2007 Hey guys.I'm trying to battle with an incredibly persistant problem in one of my scripts - regarding SQL interaction.Basically, I connect at the beginning of the script, do two queries, then the script runs... and this can take quite a while - under 10 seconds would be counted as very fortunate. Then after it's run I save the results. However, I'm getting errors occasionally on this last query ("server has gone away", "lost connection to server").I've added a mysql_ping(); line just before this query, and when it fails it returns false to this.Basically, I can direct solving this into 3 questions:1) I thought mysql_ping() auto reconnected. Do I need to add a connect line for when it returns false? What about select database?2) I'm using mysql_pconnect() at the start of the script - would I be better off using a different variation of the function, maybe closing it then reconnecting?3) Any general advice I might not of thought of? Link to comment https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/ Share on other sites More sharing options...
spfoonnewb Posted January 27, 2007 Share Posted January 27, 2007 What codes are your using for connection, etc? Link to comment https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/#findComment-170537 Share on other sites More sharing options...
wildteen88 Posted January 27, 2007 Share Posted January 27, 2007 Try a non persistent connection instead (mysql_connect not mysql_pconnect). When ever you use persistent connections make sure you are closing the connection at the end of your script or when you are finished using mysql. Link to comment https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/#findComment-170546 Share on other sites More sharing options...
Orio Posted January 27, 2007 Share Posted January 27, 2007 @wildteen88-Correct me if I a wrong, but as far as I know a persistent connection cannot be closed.From the manual:[i]"the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect())."[/i]It seems like it's closed automatically somehow....EDIT- after some reading, it appears that persistent connection just don't close.@Anidazen- Try increasing the mysql.connect_timeout directive and see if the connection still times-out.Orio. Link to comment https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/#findComment-170551 Share on other sites More sharing options...
wildteen88 Posted January 27, 2007 Share Posted January 27, 2007 [quote author=Orio link=topic=124276.msg514800#msg514800 date=1169916450]@wildteen88-Correct me if I a wrong, but as far as I know a persistent connection cannot be closed.From the manual:[i]"the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect())."[/i]It seems like it's closed automatically somehow....EDIT- after some reading, it appears that persistent connection just don't close.@Anidazen- Try increasing the mysql.connect_timeout directive and see if the connection still times-out.Orio.[/quote]mmm... I swear you could use mysql_close to close a persistent connection before. I guess they have changed that now. Link to comment https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/#findComment-170568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.