NYCPHP Meetup

NYPHP.org

[nycphp-talk] freeing sql results

jface at mercenarylabs.com jface at mercenarylabs.com
Thu Dec 7 22:58:47 EST 2006


After a lot of trial and error I've narrowed down the offending query in my problem with sql results not freeing themselves up:

$query = mysql_query("SELECT activeID FROM activeAI WHERE locationID='$locationID' AND activeID <> '$activeID' AND isUndead=0");
$numOtherAI = mysql_num_rows($query);
mysql_free_result($query);

When I comment out this query, the error(s) go away. Variables $locationID and $activeID are both properly set.

Is there something horribly wrong with this query? Is m_f_r() just not working? Too many ANDs?

Jonathan

On Tue, 5 Dec 2006 22:45:34 -0500, Jon Baer <jonbaer at jonbaer.com> wrote:
> Add a debug_print_backtrace() before the free result or query.  I
> find it to be very handy in PHP5, although I wish there was a way to
> dump the results to a UDP port for catching it as well.
>
> - Jon
>
> On Dec 5, 2006, at 8:39 PM, <jface at mercenarylabs.com>
> <jface at mercenarylabs.com> wrote:
>
>> I have a very complex app I've been working on currently at about
>> three thousand lines of code. All of a sudden it started spitting
>> out the following warning:
>>
>> Warning: Unknown: 2 result set(s) not freed. Use mysql_free_result
>> to free result sets which were requested using mysql_query() in
>> Unknown on line 0
>>
>> So I went through it line-by-line and added a mysql_free_result()
>> after EVERY query, to no avail.
>>
>> The worst thing about this error is that it doesn't give me a valid
>> line number, so it's impossible to tell exactly where the bad
>> queries are.
>>
>> This is occurring on a php5/mysql5/apache setup.
>>
>> Anyone have any suggestions? I'm out of ideas.
>>
>> Jonathan
>>
>> _______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>>
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list