in reply to if not defined question

Suggest using exists() ... but unless you are certain that an entry for $id exists at this point do not assume that it does; you should check both.