If that's all of the code that you have, it's either as oxfordian said, or your DB query doesn't return a record, so there's no record to get the ID from. Either way you'll get the same error message. It just depends which bit of the code is on line 4...
↧