Question

I have 2 tables in a query designed to display/email the saved search info of users : users & wishlist.

The search info contains book titles among other things.

I have a first query designed to put into an array all the users that have records in the wishlist table.

Then using a foreach loop, via a second query, take each book title and run a search at various sites and save that information to screen or to an email.

The first run through takes about 3 minutes for the first user's information to be assembled and yet, after this info is displayed, I see the dreaded "MySQL server has gone away".

According to http://dev.mysql.com/doc/refman/5.0/en/gone-away.html - this shouldn't happen so quickly.

The code for the second query is simple :

SELECT * FROM wishlist WHERE uid = " . $sendtouser . " ORDER BY wishid

After the information is compiled for that user, I have the following to close the loop and end the connection.

} while ($row_rsWishDetails = mysql_fetch_assoc($rsWishDetails));
mysql_free_result($rsWishDetails);

I have tried some other suggestions I have found on the web including :

ini_set('max_execution_time', 22222);
ini_set('mysql.connect_timeout', 500);
ini_set('default_socket_timeout', 600);

But nothing is fixing the problem.

Any ideas?

Thanks very much.

Was it helpful?

Solution

With long running scripts, you need to make sure that connection is still open before running any queries. The best way to do so is to use something like mysql_ping() before your query.

Also, the mysql is rather old and inefficient. You should try to upgrade to mysqli.

OTHER TIPS

you need to TEST how many data you can received.

whether your DB machine is old or your result row count is 1000000000000000000000+, you need to fix your query with paging: limit, cursor, etc...

it is not a direct solution for your question.

first, check your row count with

SELECT COUNT(*) FROM wishlist WHERE uid = " . $sendtouser . "
  • ORDER BY is not needed.

check remove ORDER BY phrase and if OK, re-arrangement with PHP code. sometimes it could be helpful.

AND...

ini_set('max_execution_time', 22222);

it is client(PHP) configuration as you know, it's useless if mysql-server not permitted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top