"Commands out of sync error" when calling stored procedure
Posted: Mon Oct 13, 2008 8:40 am
Hi,
From PHP I cannot call two stored procedure in the same connection (I
guess it depends on the fact they are returning MULTI_RESULTS, it
doesn't happen with normal SELECTs)
When I run the second one I get the following error: "Commands out of
sync; you can't run this command now" but its not showing error for first stored procedure.
Herewith i attached the code:
Please anyone help me.
Thanks,
Venu
From PHP I cannot call two stored procedure in the same connection (I
guess it depends on the fact they are returning MULTI_RESULTS, it
doesn't happen with normal SELECTs)
When I run the second one I get the following error: "Commands out of
sync; you can't run this command now" but its not showing error for first stored procedure.
Herewith i attached the code:
Code: Select all
<?php
include ("inc/db.php");
include ("inc/classLib.php");
$p = isset($_GET["p"]) ? $_GET["p"] : "";
$s = isset($_GET["s"]) ? $_GET["s"] : "";
$stmt = ("call sp_GetPresentation('".$p."')");
$result = mysql_query($stmt) or die ("an error occurred: " . mysql_error());
$rowcount = mysql_num_rows($result);
if($rowcount != 0)
{
$row = mysql_fetch_array($result);
pageHeader($row['name']);
$slides = ("call sp_GetPresSlideList('".$p."','Y')");
$slidesresult = mysql_query($slides) or die ("an error occurred: " . mysql_error());
$rowcount = mysql_num_rows($slidesresult);
print "<small>click a slide to edit</small><br /><ul id=\"firstlist\" class=\"sortableUL\">\n";
$i=1;
while($slidesrow = mysql_fetch_array($slidesresult))
{
$slide = ("call sp_GetSlide('".$slidesrow["id"]."')");
$slideresult = mysql_query($slide) or die ("an error occurred: " . mysql_error());
$rowcount = mysql_num_rows($slideresult);
$row = mysql_fetch_array($slideresult);
//print "<h3>". stripslashes($row["title"])."</h3>";
$stmt = ("call sp_GetSlideText('".$row["id"]."')");
$slidedetail = mysql_query($stmt) or die ("an error occurred: " . mysql_error());
while($slidesrow = mysql_fetch_array($slidedetail))
{
print "<li class=\"sortSlide\" id=\"firstlist_firstlist".$i."\"><a href=\"slide.php?p=".$p."&s=".$row["id"]."\"
target=\"maincontent\">".stripslashes($slidesrow["text_field"])."</a></li>\n\n";
$i++;
}
//print "</ul>";
//print "<br />";
}
print "</ul>";
//print "<br clear=\"both\" /><br /><hr width=\"50%\" align=\"left\" color=\"#860037\"><br /><a href=\"slide.php?p=".$p."\" target=\"maincontent\">Click here to add a slide</a>";
}
else
{
print "<h1>Presentation not found</h1>";
print "<a href=\"createpresentation.php\">Click here to create a presentation</a>";
}
?>
Thanks,
Venu