Quoting a SQL query in Perl

Hello,
I have the following line in my Perl program:

$sth=$dbh->prepare (qq{SELECT primarykey,firstname, middlename, lastname, flat, street, city, state, country, FROM people WHERE city = “$city” AND type = “$type” ORDER BY rating DESC LIMIT $x,4 } );

and it’s unfortunately giving me a different answer than if I type in the exact same thing into the mysql command line with values for the variables. (I swear to God, it’s exactly the same). (The values for the variables are what the above line is getting, I checked that by PRINTing them).
My question is - the only thing I can see that could mess it up is the quoting for the $x - do I need to put it within quotes? If I do, then I get no results at all in my webpage. Help!