title: Mysql select statement with inner join not working with php but works on mysql terminal
body: <p>I have three tables in mysql</p>
  
  <p><strong>Table 1: projects</strong></p>
  
  <pre><code>+----+-------------+-----------------------------+----------+---------------+
  | id | ProjectName | ProjectDescription          | projType | projectStatus |
  +----+-------------+-----------------------------+----------+---------------+
  |  1 | RAPepsi     | Retail Audit for Pepsi      |        1 |             1 |
  |  2 | RACocaco    | Retail Audit for Coke       |        1 |             1 |
  +----+-------------+-----------------------------+----------+---------------+
  </code></pre>
  
  <p><strong>Table2 : outlets</strong></p>
  
  <pre><code>id pid  poid OutletName Add1     Add2       City    Phone  interviewer Status projStat 
      1   1   11  Outlet1 Address1    Address2    City1   12345      1          1      1
      2   1   21  Outlet2 Address1    Address2    City1   12345      1          1      1
      3   2   32  Outlet2 Address1    Address2    City1   12345      3          1      1
  </code></pre>
  
  <p><strong>Table 3: Users</strong></p>
  
  <pre><code>id  username        email           password
  1   test1@gmail.com test1@gmail.com 123
  2   test2@gmail.com test2@gmail.com 123
  3   test3@gmail.com test3@gmail.com 123
  </code></pre>
  
  <p>I am trying to get the project name and description from projects table assigned to specfic interviewer from outlets table.  I have tried this code in mysql console:</p>
  
  <pre><code>select distinct(p.ProjectName),p.ProjectDescription from outlets as oo inner join projects as p on p.id = oo.pid where oo.interviewer=(select id from users where email='test1@gmail.com');
  </code></pre>
  
  <p>This fetches the correct results as desired.  However, when I use the same code in a php script where the email is dynamic, it fails to return the data:</p>
  
  <p><strong>PHP Script</strong></p>
  
  <pre><code>include "config.php";
  $conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);
  if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
  } 
  $username  = (isset($_GET['userId']))?  $_GET['userId'] : 0;
  $sql="select distinct(p.ProjectName),p.ProjectDescription from outlets as oo inner join projects as p on p.id = oo.pid where oo.interviewer=(select id from users where email='".$username."')";
  $result = $conn-&gt;query($sql);
  </code></pre>
  
  <p><strong>The above line not working in php</strong>.  I am getting the following error:  [client 103.47.158.210:56346] PHP Parse error:  syntax error, unexpected '$result' (T_VARIABLE) </p>
  
  <p>However, when i use the following code: it works:</p>
  
  <pre><code>$sql = "SELECT * FROM projects where projectStatus=1 and username= '".$username."'";
  </code></pre>
  
  <p>Ofcourse I test this with username column in my projects table.  </p>