title: MySQL Unknown column in where clause for simple select statement
body: <p>I have a very basic select statement that is causing a column unknown error. The problem with the query happens when I try to use a character instead of just numbers in the variable. Wondering if it has anything to do with Collation.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>$titleno=$_REQUEST['title_no'];
  $titleno=mysql_real_escape_string($titleno);
  $titleno = utf8_decode($titleno); //tried without this before but didn't work
  $query="SELECT * FROM `Titles` WHERE `title-no` = '".$titleno."'"; 
  //tried various versions of this query - left it as single quotes as that seems to be the correct way. This only fails when a character is entered. Numbers work fine.  
  
  echo "query - &lt;br&gt; $query &lt;br&gt;";    
  $get_title_result=mysql_query($query) or die(mysql_error());
  //here I get the unknown column name error - MySQL treats the titleno as the column name 
  </code></pre>
  
  <p>Echo output:</p>
  
  <pre><code>SELECT * FROM `Titles` WHERE `title-no` = '1234566d' 
  Unknown column '1234566d' in 'where clause'
  </code></pre>
  
  <p>If I didn't use the 'd' in title-no, it works fine....Also, I tried a different column name that doesn't have the hyphen and still get the same behavior. The DB defines collation for title-no as latin1_swedish_ci. (This problem doesn't occur when I paste the query into mysqladmin)</p>
  
  <p>Here's the table definition:</p>
  
  <pre><code>CREATE TABLE `Titles` (  
   `id` int(11) NOT NULL auto_increment,  
   `title-no` varchar(15) NOT NULL,  
    UNIQUE KEY `title-no` (`title-no`),  
    KEY `id` (`id`)  
    ) ENGINE=MyISAM  
    AUTO_INCREMENT=9090949 DEFAULT CHARSET=latin1 AUTO_INCREMENT=9090949 ;
  </code></pre>
  
  <p><strong>RESOLVED:</strong> The issue was not with this query. It was with a subsequent query. I was confused because I was only echoing this query. My bad. Thank you all for your support! :)</p>