switched to mysqli-statements and added mysqli_free_result