I've just written some code almost exactly like this..but it's at work and I'm at home..and my brain is fried so can't remember the EXACT syntax I used however....
I've found that when trying to use quotes inside a quoted string the CGI converts the ' nicely...but leave the " in and it screws it up...ALSO shouldn't there be a "+" on either side of the variable?
Texas Tess