Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7587671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:43:52+00:00 2026-05-30T19:43:52+00:00

I want to call multiple MySQL stored routines sequentially with PHP, but I can

  • 0

I want to call multiple MySQL stored routines sequentially with PHP, but I can only call a single one successfully—after that I get the error Commands out of sync; you can’t run this command now. Researching the problem I found it’s a common headache (caused by not “finishing up” the previous call before the next one is made), but I didn’t find a solution I could apply to my code:

for ($i=0; $i<10; $i+=1) 
{
    if (!($conn=getconn() && ($result=mysql_query("call MyStoredRoutine();", $conn))))
    {
        $errorMessage = mysql_error($conn); // Error 2nd time here...
    }
    else {
        while ($row=mysql_fetch_array($result)) {
            // Retrieve data here...
        }
    }
}

And the implementation of getconn() (I don’t think it’s relevant but you never know):

function getconn() {
    global $custdb, $custdb_connection, $dbuser, $dbpass;
    if (! $custdb_connection) {
        if (! ($custdb_connection = mysql_connect("localhost", $dbuser, $dbpass, true))) return false;
        if (! (@ mysql_select_db($custdb, $custdb_connection)))  return false;
    }
    return $custdb_connection;
}

PHP version is 5.3.8-1~dotdeb.1, MySQL is 5.1.54-1ubuntu4.

Anybody knows what I should do to my code to make it work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:43:54+00:00Added an answer on May 30, 2026 at 7:43 pm

    Maybe switch to MySQLi and use multi-query()

    MySQLi gives you the added benefit of prepared statements and is build to support OOP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function in R that I call multiple times. I want to
I want to call a web service, but I won't know the url till
I want to call ShowDialog() when a keyboard hook event is triggered, but I'm
hey guys i want to fetch 3 tables in 1 single ado.net call from
I want to call java function from c++ which takes multiple parameters , I
I want to call multiple delegate simultaneously in my iphone application.is it possible?if possible
I want to call oracle10g's stored procedure MyStoredProcedure from my c# .net 4 code
I want to call Java from PHP 5.2, running either on a webserver or
How to store multiple images in a MySQL database and call them back whenever
I have a PHP web application developed using symfony framework. I want to call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.