tags:

views:

30

answers:

2

I am getting the following error when trying to run a script from my site:

Warning: mysql_query() [function.mysql-query]: Unable to save result set in /home/my_site/public_html/my_file.php on line 149

$run_sql = mysql_query("SELECT count(*) from tix_orders where order_id='$uniq_transaction_id'",$conn)

I have tried analyzing and doing and extended repair on the table but still the problem persists.

A: 

Could you please post the script, or the portion of it that is accessing the db (around 149, I would assume)?

INTJat
$run_sql = mysql_query("SELECT count(*) from tix_orders where order_id='$uniq_transaction_id'",$conn)
Sonny
+1  A: 

I have never encountered this error but found out that it seems to come from a corrupt database, but can also be caused by PHP there is a PHP Databases FAQ which may be of use.

MySQL also has its own information about Table Maintenance which may also be worth looking into. I have also heard that rebooting the MySQL server has helped with the issue, have you tried that as well?

The real question is, do you have a backup? If not, can you run a dump on the data and then just re-create the database and hopefully that will fix it. I will keep doing my research, but that is what I have found so far.

EDIT

After a bit more research, found a few people who had solved this problem by running: SET SQL_BIG_TABLES=1; which should allow MySQL to use extra memory to save the result set. I am not sure of the repercussion of doing this, so you may want to do some research in MySQL on what that does and what might happen if left on.

But you providing us with more code, a possible table structure and the query you are running will help get to the bottom of the error quicker and more efficiently.

UPDATE

To try the SET SQL code do something like this:

use with caution and do your research as I do not know what issues this may cause!

mysql_query("SET SQL_BIG_TABLES=1");
$run_sql = mysql_query("SELECT count(*) from tix_orders where order_id='$uniq_transaction_id'",$conn);
mysql_query("SET SQL_BIG_TABLES=0");

That way it only sets it temporary. Although I would consider this a bandaid and would still suggest a database rebuild via a dump of data through the command line mysqldump, as the error seems to be closely related to corrupt tables.

Brad F Jacobs
Thanks for your help. Here is line 149: $run_sql = mysql_query("SELECT count(*) from tix_orders where order_id='$uniq_transaction_id'",$conn);
Sonny
I have rebooted mysql as well as the server but that didn't seem to help.
Sonny
Where do I run "SET SQL_BIG_TABLES=1;"? Within the php code itself?
Sonny
Generally through the MySQL command line, but you should be able to query it through `mysql_query`. Updated my response.
Brad F Jacobs
Well using SET SQL_BIG_TABLES=1; got rid of the original error, however, the following errors still remain wherever I actually run the query.Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /path/ on line 151
Sonny
Thanks for all your help. Even though a table analysis and an extended repair showed all tables were okay, the problem was a corrupt table. Renaming the old table, creating a new one and then importing only the important data resolved the issue.
Sonny