Yes, you were using $result instead of $sql, but make a habit in telling us how you've solved your problems.
It's just great when you have op's skull-aching problem, and at the end he's bursting with joy and fluffy and pinkish confetti cuz he's worked it out somehow, and there you are - dumb-staring at the screen, after hours of trying to get that damned code together, swearing, stabbing, throwing the mouse at the cat and the laptop at your mother, wondering what the heck he has done, having that feeling of sand in your eyes and your urinary meatus, a reaction to the sheer noxious, narcissistic manner in which that heartless, baby-eating, self-centered, triple-horned, negative-empathy op posted on the forums.
But, hey, we're glad you're glad.
(this is a joke, with a drop of acid truth in it. so don't flame it. i'm actually in a good mood. I also like potato chips)