title: codeigniter : Commands out of sync; you can't run this command now
body: <p>I applied all the possible answers but still same problem.
  also tried </p>
  
  <pre><code>$this-&gt;db-&gt;reconnect();
  </code></pre>
  
  <p>there is no problem in my query</p>
  
  <p><a href="https://i.stack.imgur.com/U5wcN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U5wcN.png" alt="enter image description here"></a></p>
  
  <p>MyCode:</p>
  
  <pre><code>public function GetdistributorsDetails($username){
          $sql = "SELECT u.FirstName, u.Email, u.Telephone, u.MobileNumber, u.AlternateMobileNumber, ud.Address1, ud.Pincode,ud.City,s.Statename FROM users u JOIN userdetails ud ON ud.UserId = u.UserId JOIN states s ON s.StateId = ud.StateId WHERE u.Username = ? ";
          $result = $this-&gt;db-&gt;query($sql,array($username));
          return $result-&gt;result_array();
      }
  </code></pre>