Home Theatre PC
  Home / Archived / Mysql has gone away solution!   
Categories
Manufacturers

Quick Find

Use keywords to find the product you're looking for
What's New? more
Antec Quattro 1200 1200W TruePower Power Supply
Antec Quattro 1200 1200W TruePower Power Supply
Polls
Do you own a 3D TV?
Yes, I love it!
Yes, but I mainly use it as a 2D TV
No, but I will be buying one in the next 12 months
No, I'm not really interested in 3D TV
[ Results ]
RSS Feeds
RSS Feed  Latest News
RSS Feed  What's New?
RSS Feed  Categories

What is RSS?
SSL Security Info
You are viewing a part of our web site that does not require a secure connection.



What is SSL?

Mysql has gone away solution!

 Date: Sunday 06 June, 2010
News Content

Recently, we have been getting some 'MySQL has gone away' errors for some of our scripts that take a long time to run without making a mysql call.

We have been searching for a solution to this for sometime now, but have been unable to find a good solution, until now!

We stumbled upon php's mysql_ping() function which has solved the issue and thought we would share the solution with other oscommerce store owners that may be experiencing the same issue.

Step 1. Backup as always!

Step 2. In your includes/functions/database.php file, add the following function :-

function tep_db_reconnect($link = 'db_link') {
global $$link;

if (!mysql_ping($$link)) {
tep_db_close();
tep_db_connect();
}
}

Step 3. call tep_db_reconnect() function from the tep_db_query() function in your includes/functions/database.php file :-

function tep_db_query($query, $link = 'db_link') {
global $$link;

tep_db_reconnect(); // reconnect if Mysql has gone away

[snip...]
}

Step 4: repeat steps 2 and 3 for your admin/includes/functions/database.php file.

Note: this will not really help you if your ISP's mysql server is overloaded, as that's a totally different issue. This only helps to resolve a mysql connection that has timed out.

Please feel free to contact us with any questions you may have.texttext
Mysql Logo
Back Continue
Latest News more
New Usana Canada Store!
Merry Christmas!
Holiday Trading Hours
New Usana New Zealand Store
Sponsored Links


Specials more
X10 CM12 Programmable Computer Interface (USB lead) (OEM)
X10 CM12 Programmable Computer Interface (USB lead) (OEM)
$145.00
$136.00
Currencies
Renting
flexirent
How to Rent?

Terms & Conditions | Privacy Notice | Reward Points | Payment & Credit Cards | Shipping & Returns | News | Contact Us
Affiliate Terms & Conditions | Affiliate Program | Affiliate Login

  and 
follow us on twitter
follow us @hometheatrepc
become a fan on facebook
become a fan
Copyright © 2004-2017 Better Computers Australia Pty Ltd
All prices, specifications, availability, and terms of offers are subject to change without notice.
Stock Status is updated once daily and products marked as In Stock could be sold out at time of purchase.
Images are for illustration purposes only and may not represent actual products.
Buy USANA Essentials or USANA Healthpak from our health store.