PHP does not report an error when calling the MYSQL stored procedure. Two days ago, I worked with my colleagues to develop an inventory management system. I was responsible for writing the page program, and my colleagues were responsible for writing the stored procedure. when writing the program, everything went smoothly until the development was completed, I used PHP to develop an inventory management system with my colleagues two days ago. I was responsible for writing the page program, and my colleagues were responsible for writing the storage process. when writing the program, everything went smoothly until the development was completed, the problem occurred when I used PHP to call his stored procedure.
Pay attention to the following points during future development:
1. pay attention to the last two parameters when connecting to the MYSQL database.
Define ('Client _ MULTI_RESULTS ', 131072); // defines a constant
$ Conn = mysql_connect ("localhost", "root", "123456", 1, CLIENT_MULTI_RESULTS );
$ Db = mysql_select_db ("db01", $ conn );
2. call the stored procedure method
There are two simple methods.
(1) No Return value
Mysql_query ("call nj_keep_accounts_sp ($ id)", $ conn); // stored procedure name: nj_keep_accounts_sp parameter: $ id
(2) return values
$ Id = $ _ GET ["id"];
$ R = mysql_query ("call nj_keep_accounts_sp ($ id)", $ conn );
While ($ rs = @ mysql_fetch_array ($ r )){
Echo ($ rs ["t_id"]);
}
3. if no error is reported during debugging, the execution is unstable and will be easy to use later. Please note that
I encountered this kind of thing during the test and found that the code itself was correct, and the stored procedure was not executed in MYSQL. Where did the problem happen?
After two days of testing, it is found that the test return value is added to the execution start, center, and end parts during the debugging of the stored procedure. The problem occurs here.
I fixed the useless return values (for example, select @ a) and found that all the previous problems were solved after the code was fully annotated, and the program was also useful.
From newsera
...