I have a php script that runs a mysql query, then loops the result, and in that loop also runs several queries:
$sqlstr = \"SELECT * FROM user_pred WHERE
The unset call is pointless/irrelevant. Try with mysql_free_result though - It might have some effect.
unset