Jump to content

A few MYSQL questions


Anidazen

Recommended Posts

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
Share on other sites

@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
Share on other sites

[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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.