At 6/18/2008 02:47 PM, Paul Novitski wrote:
I've got a simple script running as a cron job that's getting
intermittent "Lost connection to MySQL server during query" errors.
At 6/18/2008 10:43 PM, Chris wrote:
You need to do a
mysql_close();
mysql_connect(...)
before mysql_query works again - otherwise mysql_connect will just
return the same resource id (or I guess just use the 'new_connection'
flag for mysql_connect and skip the mysql_close()).
Thanks! Adding the new_link parameter to mysql_connect() did the trick.
What had me stumped before was that each mysql_connect() succeeded
but the mysql_select_db() immediately afterward failed. But as the
documentation says:
"new_link
"If a second call is made to mysql_connect() with the same
arguments, no new link will be established, but instead, the link
identifier of the already opened link will be returned. The
new_link parameter modifies this behavior and makes mysql_connect()
always open a new link, even if mysql_connect() was called before
with the same parameters."
http://ca3.php.net/mysql_connect
Reminder to self: RTFM doesn't always work if you think you know the
page and don't re-read it with new eyes.
Cheers,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php