PHP does not report an error when calling the MYSQL stored procedure _ PHP Tutorial

Source: Internet
Author: User
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

...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.