2

This code is working correctly on my localhost (Xampp, PHP 5.4) but when I deploy this code on a server (Wamp, PHP 5.5), it's firing this error for $mysqli->multiquery().

Here is my code:

if($mysqli->multi_query("CALL `wc_new_tyre_article` ('$season','$dimB','$dimQ','$dimD','$com_id','$adr_id')")){
            do{
                if($result = $mysqli->store_result( )){

                    while($row = $result->fetch_object( )){
                        if(isset($row->empty))
                            break 1;
                        $articleId = $row->ART_ID;
                        $ggrId = $row->GGR_ID;
                        $articles[] = $row;
                    }
                    $result->close();
                }
            }while($mysqli->next_result() && $mysqli->more_results());
            for($index = 0;$index<count($articles);$index++){
                $articleId = $articles[$index]->ART_ID;
                $ggrId = $articles[$index]->GGR_ID;
                if(!empty($articleId) && !empty($ggrId)){
                    if($stk_results = $mysqli->query("CALL `wc_get_stock` ('$articleId','$ggrId','$com_id')")){
                       while($rows = mysqli_fetch_object($stk_results)){
                           $articles[$index]->STOCK = $rows;
                           while($mysqli->next_result()){
                                if($l_result = $mysqli->store_result())
                                    $l_result->free();
                            }
                       }
                    }
                }
            }

            return $articles; 

As per above code first I am calling wc_new_tyre_article which return multiple result set. Using this results I call another SP wc_get_stock to fetch another results.

I have tried all solutions which are was available here but none of them are working.

I have tried error_reporting(E_ALL ^ E_STRICT).

halfer
  • 19,824
  • 17
  • 99
  • 186
rut2
  • 706
  • 1
  • 9
  • 29
  • read this: http://php.net/manual/en/mysqli.multi-query.php#102837 – Marco Mura Dec 15 '14 at 08:43
  • @Marco I guess my code is correct multi_query results will be flush in do_while - as per refrence. and then mysqli->query will be executed. So it should be work. And beside I can get absolutely coreect results on my localhost. problem occures in live serve. what you think ? – rut2 Dec 15 '14 at 08:48
  • as the comment i've linked says this is not needed, && $mysqli->more_results() but your error do says so. Maybe putting both will create trouble, like advancing two rows at a time? – Marco Mura Dec 15 '14 at 08:49
  • maybe this other comment rut -> http://php.net/manual/en/mysqli.multi-query.php#114544 – Marco Mura Dec 15 '14 at 08:49
  • Yes actully u have point, thanks but I had only $mysqli->next_result() before but I modifid it after http://stackoverflow.com/questions/14715889/strict-standards-mysqli-next-result-error-with-mysqli-multi-query reading this. but point is if I put only $mysqli->next_result() then it is also firing same problem no change in error. And in both case I can get results corectly on my PC but for both case I can not get results on live server ;) its really headache – rut2 Dec 15 '14 at 08:53
  • my last comment link is useful? – Marco Mura Dec 15 '14 at 08:54
  • I didn't check let me check this first. It will took a while I need to check this no local and then deploy it. so thanks for reference – rut2 Dec 15 '14 at 08:56
  • do not worry, but her/his idea to use a do-while to avoid that error maybe it's useful – Marco Mura Dec 15 '14 at 08:57

1 Answers1

1

If you are doing a CALL query, does that mean you have just finished doing a CREATE PROCEDURE query? Can we see this portion? Is there something out of sync before we get to the start of your multi_query? Did you check $mysqli->error before running multi_query?

I don't have any experience with CALL queries, but I read somewhere that 1 CALL query can return >1 results sets. How many result sets is yours returning? Do you need to pull next_result and more_results out of the do while condition to properly handle >1 result set?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136