Jump to content

how to get out put parameter's value in php.


naeembhatti

Recommended Posts

hi friends h r u?
i use simple stored procedure e.g
in mysql=============================
CREATE PROCEDURE `test`.`users` (OUT returnval int)
BEGIN
set returnval = 100;
END //
how to get its value in php===================i am currently using this

$mysqli = new mysqli("localhost", "root", "bhatti", "test");

if (mysqli_connect_errno())
{
  printf("Connection failed: %s\n", mysqli_connect_error());
  exit();
}

$SQL = "CALL users(@retval)";
if (!$mysqli->real_query($SQL))
{
  printf("Invalid query: %s\nWhole query: %s\n", $mysqli->error, $SQL);
  exit();
}

if ($result = $mysqli->store_result())
{
  while ($myrow = $result->fetch_array(MYSQLI_ASSOC))
  {
      print_r($myrow);
  }
  $result->close();
}

$mysqli->close();

=======================================

but when i wrote in phpmyadmin like CALL users(@retval); SELECT @retval; it returns me value but how to get it in php?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.