Sunday, 15 May 2011

mysql - PHP Stored Procedure error when calling sequentially or more than once -


itemprop = "text">

I have two menus that use stored procedure Let us name it menu 1 and menu 2. This code is for Menu 1: This is a code for Menu 2 too.

  & lt; Php $ sql = $ mysqli- & gt; Query ("Call Selection Products ()"); $ I = 1; While ($ row = mysqli_fetch_array ($ sql)) {$ id = $ line ['prodid']; $ Date = $ line ['ProdName']; $ Items = $ line ['proddescription']; $ Qtyleft = $ line ['prodsupplier']; $ Qty_sold = $ line ['proddate']; $ Cost = $ line ['prodprice']; $ Sales = $ line ['prodquantity']; If ($ i% 2) {? & Gt; & Lt; Tr id = "& lt ;? php ek $ id ;? gt;" Class = "edit_tr" & gt; & Lt ;? Php} and {? & Gt; & Lt; Tr id = "& lt ;? php ek $ id ;? gt;" Bgcolor = "# f2f2f2" class = "edit_tr" & gt; & Lt ;? Php}? & Gt; & Lt; Td class = "edit_td" & gt; & Lt; Span class = "text" & gt; & Lt ;? Php echo $ date; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span class = "text" & gt; & Lt ;? Php ek $ item; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span class = "text" & gt; & Lt ;? Php echo $ qtyleft; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span id = "last_ <" php echo $ id;? & Gt; " Class = "text" & gt; & Lt ;? Php echo $ qty_sold; ? & Gt; & Lt; / Span & gt; & Lt; Input type = "text" value = "& lt ;? php echo $ rtrt ;? & gt;" Class = "editbox" id = "last_input_ <" php echo $ id;? & Gt; " /> & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span id = "first_ & lt ;? php echo $ id ;? & gt;" Class = "text" & gt; & Lt ;? Php echo $ value; ? & Gt; & Lt; / Span & gt; & Lt; Input type = "text" value = "& lt ;? php echo $ price ;? & gt;" Class = "editbox" id = "first_input_ <" php echo $ id;? & Gt; " / & Gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span class = "text" & gt; & Lt ;? Email Php $ dailysales; ? & Gt; & Lt ;? Php $ sales; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php $ i ++; }? & Gt;   

My problem occurs when I call the stored procedure in Menu1 , but there is an error in Menu2

Depending on my research, this code may be an error because I am calling the stored procedure sequentially.

This code will be used to call the stored procedure a second time How to modify? I'm really confused with this one. It seems that the first stored procedure needs to be stopped, before I can call the stored procedure again. I really do not know how to do this.

I'm guessing that you get "out of sync" error?

Before you can make a second call to the database on the same connection, you will need to release the resources by calling Closed () on your results set. Since you named your result variable $ sql , call you $ sql-> close () .

For example:

  & lt ;? Php if ($ result = $ mysqli- & gt; query ("call selectproducts ()")) {$ i = 1; While ($ row = mysqli_fetch_array ($ result)) {$ id = $ row ['prodid']; $ Date = $ row ['prodname']; $ Items = $ line ['proddescription']; $ Qtyleft = $ line ['prodsupplier']; $ Qty_sold = $ line ['prod']; $ Value = $ line ['prodprice']; $ Sales = $ line ['prodquantity']; If ($ i% 2) {? & Gt; & Lt; Tr id = "& lt ;? php ek $ id ;? gt;" Class = "edit_tr" & gt; & Lt ;? Php} and {? & Gt; & Lt; Tr id = "& lt ;? php ek $ id ;? gt;" Bgcolor = "# f2f2f2" class = "edit_tr" & gt; & Lt ;? Php}? & Gt; & Lt; Td class = "edit_td" & gt; & Lt; Span class = "text" & gt; & Lt ;? Php echo $ date; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; Td> & Lt; Span class = "text" & gt; & Lt ;? Php echo $ item; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; Td> & Lt; Span class = "text" & gt; & Lt ;? Php echo $ qtyleft; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span id = "last_ <" php echo $ id;? & Gt; " Class = "text" & gt; & Lt ;? Php echo $ qty_sold; ? & Gt; & Lt; / Span & gt; & Lt; Input type = "text" value = "& lt ;? php echo $ rtrt ;? & gt;" Class = "editbox" id = "last_input_ <" php echo $ id;? & Gt; " /> & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span id = "first_ & lt ;? php echo $ id ;? & gt;" Class = "text" & gt; & Lt ;? Php echo $ value; ? & Gt; & Lt; / Span & gt; & Lt; Input type = "text" value = "& lt ;? php echo $ price ;? & gt;" Class = "editbox" id = "first_input_ <" php echo $ id;? & Gt; " / & Gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Span class = "text" & gt; & Lt ;? Email Php $ dailysales; ? & Gt; & Lt ;? Php $ sales; ? & Gt; & Lt; / Span & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php $ i ++; } $ Result-> Close (); }? & Gt;    

No comments:

Post a Comment