The url variable is never defined
Yes it is, just before the pasted section.
oh you are right, nevermind then