title: statement causes while loop error
body: <p>I have some PHP/SQL written to populate a selection list with data from a database with the option being populated based on a prior entry in a text box.$pk is accepted perfectly and is a valid ARTICLE_NO, and the query works perfectly when executed directly by mysql. I have put output statements after every event and all except tetsing while executes. The while loop is never entered, and I am unsure why. Here is my code :</p>
  
  <p>edit: I have narrowed the problem down to the fact that 0 rows are returned, but I have no idea why as the same query in phpmyadmin gives the right result.</p>
  
  <pre><code>    if (!$getRecords-&gt;fetch()) {
      printf("&lt;p&gt;ErrorNumber: %d\n", $getRecords-&gt;errno);
  }
  </code></pre>
  
  <p>It shows that the errno is 0. So no records are fetched, and there is no error, yet it is a valid query.</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', '1');
  error_reporting(E_ALL);
  $pk = $_GET["pk"];
  $con = mysqli_connect("localhost", "", "", "");
  if (!$con) {
      echo "Can't connect to MySQL Server. Errorcode: %s\n". mysqli_connect_error();
      exit;
  }
  $con-&gt;set_charset("utf8");
  echo "test outside loop";
  if(1 &lt; 2) {
      echo "test inside loop";
      $query1 = 'SELECT ARTICLE_NO FROM AUCTIONS WHERE ARTICLE_NO = ?';
      if ($getRecords = $con-&gt;prepare($query1)) {
  echo "inside second loop";
          $getRecords-&gt;bind_param("i", $pk);
  echo "test after bind param";
          $getRecords-&gt;execute();
  echo "test after bind execute";
          $getRecords-&gt;bind_result($ARTICLE_NO);
  echo "test after bind result";
          while ($getRecords-&gt;fetch()) {
              echo "test inside while";
              echo "&lt;h1&gt;".$ARTICLE_NO."&lt;/h1&gt;";
          }
      }
  }
  </code></pre>
  
  <p>edit:</p>
  
  <p>I tried with this code:</p>
  
  <pre><code>&lt;?php
  $mysqli = new mysqli("localhost", "", "", "");
  $pk = $_GET["pk"];
  if (mysqli_connect_errno()) {
      printf("Connect failed: %s\n", mysqli_connect_error());
      exit();
  }
  /* prepare statement */
  if ($stmt = $mysqli-&gt;prepare("SELECT ARTICLE_NAME, WATCH FROM AUCTIONS WHERE ARTICLE_NO = ? LIMIT 5")) {
      $stmt-&gt;bind_param("i", $pk);
      $stmt-&gt;execute();
      /* bind variables to prepared statement */
      $stmt-&gt;bind_result($col1, $col2);
      /* fetch values */
      while ($stmt-&gt;fetch()) {
          printf("%s %s\n", $col1, $col2);
      }
      /* close statement */
      $stmt-&gt;close();
  }
  /* close connection */
  $mysqli-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>This works without $pk, if I take away the parameters it works fine. It is not a problem with getting pk via GET, because if I assign $pk = 1; instead it still fails.</p>
  
  <p>edit: the problem was that mysqli could not handle bigint, I am now using k as a string and it works fine.</p>