NYCPHP Meetup

NYPHP.org

[nycphp-talk] freeing sql results

Ken Robinson kenrbnsn at rbnsn.com
Thu Dec 7 22:34:04 EST 2006


At 10:58 PM 12/7/2006, jface at mercenarylabs.com wrote:
>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.

You really should check for errors when doing a mysql_query. Putting 
the query in a separate string helps.

$q = "SELECT activeID FROM activeAI WHERE locationID='$locationID' 
AND activeID <> '$activeID' AND isUndead=0";
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
$numOtherAl = mysql_num_rows($rs);
mysql_free_result($rs);

Ken





More information about the talk mailing list