Solved

php warning: mysql_free_result(): supplied argument is not a valid MySQL result

Posted on 2007-12-01
6
2,372 Views
Last Modified: 2013-12-12
I keep getting this warning in a phpbb2 script after adding a mod (i must say that this file hasn't been edited)

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/db/mysql4.php on line 319

This is the code in that line of the file:

            if ( $query_id )
            {
                  unset($this->row[$query_id]);
                  unset($this->rowset[$query_id]);

                  mysql_free_result($query_id); //line 319

                  return true;
            }
            else
            {
                  return false;
            }
      }

How can i fix this??

When i print the content of the variable $query_id I get  this "Resource id #351"
0
Comment
Question by:axtur
  • 2
  • 2
  • 2
6 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390120
try and track down where $query_id is declared, and see if it is a connection link to mysql database.

You can temporarily suppress the error message:
@mysql_free_result($query_id);

but off course, you should fix up the error if possible.
0
 

Author Comment

by:axtur
ID: 20390137
It is in this function:


      function sql_freeresult($query_id = 0)
      {
            if( !$query_id )
            {
                  $query_id = $this->query_result;
            }

            if ( $query_id )
            {
                  unset($this->row[$query_id]);
                  unset($this->rowset[$query_id]);
                  mysql_free_result($query_id);

                  return true;
            }
            else
            {
                  return false;
            }
      }
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390155
This may be relevant to your problem:
http://www.opentools.de/archive/index.php?t=5330

PLease try and see if this helps.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
ID: 20390341
try this
function sql_freeresult($query_id = 0)

      {

            if( !$query_id )

            {

                  $query_id = $this->query_result;

            }
 

            if ( $query_id )

            {

                  unset($this->row[$query_id]);

                  unset($this->rowset[$query_id]);

                 

				 if(is_resource($query_id)) {

				 

				  mysql_free_result($query_id);

				

				}

                  return true;

            }

            else

            {

                  return false;

            }

      }

Open in new window

0
 
LVL 20

Expert Comment

by:steelseth12
ID: 20390376
the @mysql_free_result( suggested by nizsmo only hides the error .
The above solves the problem .
0
 

Author Closing Comment

by:axtur
ID: 31412156
Solved, great answer, it also helped me solve another problem.
Thank you!!!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now