title: MySQL query doesn't work within PHP file
body: <p>I have this piece of php - mysql code:<br/></p>
  
  <p>When a user tagged in my database as a woman opens the page it queries the database for some data with the number 1012,1013,1014 else only 1012,1013.</p>
  
  <pre><code>// $php_variable=2 
  
              $SQL_M = "SELECT @gender:=$php_variable, B.id, B.notes, B.time_logged
              FROM database.evs B
              INNER JOIN (select @gender:=0) as Something
              WHERE
              CASE WHEN @gender=2
              THEN (B.items IN ('1012', '1013', '1014'))
              ELSE (B.items IN ('1012', '1013'))
              END
              ORDER BY B.time_logged ASC";
  
  
              $result = mysql_query($SQL_M);
              $mycount = mysql_num_rows($result);
              if ($mycount &gt; 0)  {
                  while ($mrow = mysql_fetch_array($result))
                  {
                      extract($mrow);
                      echo "&gt;&gt;&gt;&gt;".$id."&lt;br/&gt;"
                      //Works locally - not on server.
                  }
              }  
  </code></pre>
  
  <p>$php_variable is 2.<br/></p>
  
  <p>It should output items with item id in : 1012,1013,1014<br/>
  Instead it outputs results for items in 1012,1013.</p>
  
  <p>The strange thing is that I tested this query locally (from php and mysql query alone) 
  and on the server (Plesk - Mysql) and it runs just fine. </p>
  
  <p>It doesn't run within the php file in the server -also the ORDER is not functioning properly.</p>
  
  <p><em>The query that should execute is:</em>           </p>
  
  <pre><code>$SQL_M = "SELECT B.id, B.notes, B.time_logged
  FROM database.evs B
  WHERE B.items IN ('1012', '1013', '1014')
  ORDER BY B.time_logged ASC";
  </code></pre>
  
  <p><em>Php version: 5.16</em> (Local and server)<br/>
  <em>MySQL version: 5.0.77</em> (local and server)</p>
  
  <p>Thanks in advance for your help.</p>