# Quoting a SQL query in Perl

**URL:** <https://forum.kirupa.com/t/quoting-a-sql-query-in-perl/280524>\
**Category:** programming\
**Created:** [January 28, 2009, 3:20pm UTC](https://forum.kirupa.com/t/quoting-a-sql-query-in-perl/280524 "2009-01-28T15:20:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamhere](https://avatars.discourse-cdn.com/v4/letter/i/c57346/32.png) [@iamhere](https://forum.kirupa.com/u/iamhere)\
**Post date:** [January 28, 2009, 3:20pm UTC](https://forum.kirupa.com/t/quoting-a-sql-query-in-perl/280524/1 "2009-01-28T15:20:50Z")

</div>

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!
