Jump to content

PHP/MySqli - calling same stored procedure multiple times


pstevereynolds

Recommended Posts

I've looked through the forums and read through www.mysql.com and php.net, etc. I'm sure I'm missing something really simple. I'm playing with Stored procedures using php 5.03 and Mysql 5.0.27 with client 5.0.51a. I'm having an issue calling the same stored procedure twice. here's the very dumbed down code that I'm trying to get working.

 

<?php
include_once("db_mysqli_connection.php");
echo "database connected in test.php. <br />";
echo "Query is get_downline.<br />";

$userID = 2;
$query = "call get_downline ($userID)";
$result = mysqli_multi_query($link,$query) or die ("query - call failed : " . mysql_error());
$result = mysqli_store_result($link);
$row = mysqli_fetch_array($result, MYSQL_ASSOC);

$username = $row['FirstName'].' '.$row['LastName'];
$userID = $row['ID'];
echo "user is ".$username." with userid = ".$userID."<br />";

$query = "call get_downline ($userID)";
echo "Try calling the query again.<br />";
mysqli_free_result($result);
$userID = 4;
$query = "call get_downline ($userID)";
echo "query renamed as query2.<br />";
$result = mysqli_multi_query($link,$query) or die ("query2 - call failed : " . mysql_error());
$result = mysqli_store_result($link);

$row = mysqli_fetch_array($result, MYSQL_ASSOC);
$username = $row['FirstName'].' '.$row['LastName'];
$userID = $row['ID'];
echo "user is ".$username." with userid = ".$userID,"<br />";

echo "end";
?>

 

I get this output:

database connected in test.php.

Query is get_downline.

user is Mary Smith with userid = 4

Try calling the query again.

query renamed as query2.

query2 - call failed :

 

Notice there is not an error message to look up. I don't understand what I'm doing wrong. Why can't I call the same procedure a second time. I'm using the mysqli_free_result. Any help is much appreciated. Thanks,

Steve

 

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.