PHP + MySql + Stored Procedures, how do I get access an “out” value?

By : mmattax

Documentation is severely lacking on anything to do with stored procedures in mysql with PHP. I currently have a stored procedure that I call via PHP, how can I get the value of an out parameter?

By : mmattax


it looks like it's answered in this post:,198596,198717#msg-198717

With mysqli PHP API:

Assume sproc myproc( IN i int, OUT j int ):

$mysqli = new mysqli(  "HOST", "USR", "PWD", "DBNAME" );
$res = $mysqli->multi_query( "CALL myproc($ivalue,@x);SELECT @x" );
if( $res ) {
  $results = 0;
  do {
    if ($result = $mysqli->store_result()) {
      printf( "<b>Result #%u</b>:<br/>", ++$results );
      while( $row = $result->fetch_row() ) {
        foreach( $row as $cell ) echo $cell, "&nbsp;";
      if( $mysqli->more_results() ) echo "<br/>";
  } while( $mysqli->next_result() );

Generate cryptographically strong (potentially) random 8-character string using the openssl_random_pseudo_bytes function:

echo openssl_random_pseudo_bytes(4);
By : mike

This video can help you solving your question :)
By: admin