title: PHP stored procedure parameters
body: <p>I have created a test database as follows:</p>
  
  <pre><code>USE test;
  DROP TABLE IF EXISTS test;
  DROP PROCEDURE IF EXISTS testparams;
  CREATE TABLE test
  (
    inparm INT,
    inoutparam INT,
    outparm INT
  );
  
  INSERT INTO test VALUES (0, 0, 0);
  
  DELIMITER $$
  CREATE PROCEDURE testparams(IN i INT, INOUT io INT, OUT o INT)
  BEGIN
     UPDATE test SET inoutparm = io + 1, outparm = FLOOR(RAND() * 1000)
                 WHERE inparm = i; 
  
     SELECT outparm INTO o FROM test WHERE inparm = i;
     SELECT inoutparam INTO io FROM test WHERE inparm = i;
  
  END $$
  </code></pre>
  
  <p>I have also got a PHP script:</p>
  
  <pre><code>&lt;?php
  
  $c = new mysqli('localhost', 'test', 'test', 'test') or die('Cannot connect');
  echo "Connected\n";
  
  $in = 0;
  $out = -1;
  $inout = 3;
  
  echo "In: $in Out: $out: Inout: $inout\n";
  
  $s = $c-&gt;prepare('CALL testparams(?, ?, ?)') or die('Unable to prepare: ' . $c-&gt;error);
  $s-&gt;bind_param('iii', $in, $inout, $out);
  #$s-&gt;bind_result($out, $inout);
  $s-&gt;execute();
  
  echo "After execute SP\nIn: $in Out: $out: Inout: $inout\n";
  
  echo "End of SP\n";
  $s = $c-&gt;prepare('SELECT inparm, inoutparam, outparm FROM test');
  
  # $s-&gt;bind_result($in, $inout, $out); - Get a error here
  
  $s-&gt;execute();
  while ($s-&gt;fetch())
  {
      echo "In: $in Out: $out: Inout: $inout\n";
  }
  
  ?&gt;
  </code></pre>
  
  <p>My problem is that the stored procedure does not appear to be called. Is this due to using <code>OUT</code> and <code>INOUT</code> parameters? If so how do you use these parameters with PHP?</p>
  
  <p>This is demonstrated by the script generating the following output</p>
  
  <pre><code>Connected
  In: 0 Out: -1: Inout: 3
  End of SP
  In: 0 Out: 0: Inout: 0
  </code></pre>