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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.