title: PreparedStatement select with php not working as expected
body: <p>I have this query:</p>
  
  <pre><code>SELECT id, result, ip_address, added_date
  FROM results
  WHERE course_id = ( 
  SELECT id
  FROM courses
  WHERE course =  'informatica'
  AND macro_course_id = ( 
  SELECT id
  FROM macro_courses
  WHERE macro_course =  'scienze-matematiche-fisiche-e-naturali'
  AND organization_id = ( 
  SELECT id
  FROM organizations
  WHERE organization =  'universita-degli-studi-di-torino'
  AND city_id = ( 
  SELECT id
  FROM cities
  WHERE city =  'torino'
  AND region_id = ( 
  SELECT id
  FROM regions
  WHERE region =  'piemonte' ))))) ORDER BY id DESC
  </code></pre>
  
  <p>And i'm using this code to do it with a preparedstatement</p>
  
  <pre><code>public function getResults($region, $city, $organization, $macro_course, $course) { //works
      //added_date=datetime : YYYY-MM-DD HH:mm:ss
      echo "SELECT id, result, ip_address, added_date
      FROM results
      WHERE course_id = ( 
      SELECT id
      FROM courses
      WHERE course =  '$course'
      AND macro_course_id = ( 
      SELECT id
      FROM macro_courses
      WHERE macro_course =  '$macro_course'
      AND organization_id = ( 
      SELECT id
      FROM organizations
      WHERE organization =  '$organization'
      AND city_id = ( 
      SELECT id
      FROM cities
      WHERE city =  '$city'
      AND region_id = ( 
      SELECT id
      FROM regions
      WHERE region =  '$region' ))))) ORDER BY id DESC"; //just for me to know what query is being executed 
  
  
      if ($stmt = $this-&gt;mysqli-&gt;prepare(("
      SELECT id, result, ip_address, added_date
      FROM results
      WHERE course_id = ( 
      SELECT id
      FROM courses
      WHERE course =  ?
      AND macro_course_id = ( 
      SELECT id
      FROM macro_courses
      WHERE macro_course =  ?
      AND organization_id = ( 
      SELECT id
      FROM organizations
      WHERE organization =  ?
      AND city_id = ( 
      SELECT id
      FROM cities
      WHERE city =  ?
      AND region_id = ( 
      SELECT id
      FROM regions
      WHERE region =  ? ))))) ORDER BY id DESC
  
    "))) {
          $return = array();
          $stmt-&gt;bind_param('sssss', $course, $macro_course, $organization, $city, $region);
          $stmt-&gt;execute();
          if ($stmt-&gt;fetch()) {
              $i = 0;
              while ($row = $stmt-&gt;fetch()) {
                  print_r($row);//this is never reached
                  continue;
                  $s = new Result($row['result'], $row['added_date'], $row['id']);
                  $return[$i] = $s;
                  $i+=1;
              }
          }
      }
      return $return;
  }
  </code></pre>
  
  <p>The problem is that this function returns 0 rows and 0 errors (checked with <code>$this-&gt;mysqli-&gt;error</code>), it seems that $row = $stmt->fetch() is always false.</p>
  
  <p>However, if i copy and execute on PHPMyAdmin the output i get at the function top, i see </p>
  
  <pre><code>Showing lines 0 - 0 ( 1 total, Query time 0.0003 sec)
  </code></pre>
  
  <p>So the query returns a line but it is not catched by php. What am i missing? How can i fix this?</p>