Php calls the stored procedure to return the result set and solves the cantreturnaresultsetinthegivencontext error.

Source: Internet
Author: User
Php (as the mainstream development language) is required to call the stored procedure, return a result set, and find it difficult. after searching for a long time, I finally found a solution on a foreign forum, here we will localize it. The key is two points: 1) define (CLIENT_MULTI_RESULTS, 131072); 2) & #36; linkMySQL (the most Syn used with PHP)

Php (as the mainstream development language) is required to call the stored procedure, return a result set, and find it difficult. after searching for a long time, I finally found a solution on a foreign forum, here we will localize it.

Two key points

1) define (CLIENT_MULTI_RESULTS, 131072 );

2) $ link = MySQL (the best combination with PHP) _ connect ("127.0.0.1", "root", "", 1, CLIENT_MULTI_RESULTS) or die ("cocould not connect: ". mySQL (the best combination with PHP) _ error ());


The following is an example program.

 

Define (CLIENT_MULTI_RESULTS, 131072 );

$ Link = MySQL (best combination with PHP) _ connect ("127.0.0.1", "root", "", 1, CLIENT_MULTI_RESULTS) or die ("cocould not connect :". mySQL (the best combination with PHP) _ error ());
MySQL (best combination with PHP) _ select_db ("vs") or die ("cocould not select database ");
?>

$ Result = MySQL (the best combination with PHP) _ query ("call get_news_from_class_id (2)") or die ("Query failed :". mySQL (the best combination with PHP) _ error ());
While ($ row = MySQL (the best combination with PHP) _ fetch_array ($ result, MySQL (the best combination with PHP) _ ASSOC ))
{
$ Line =. $ Row ["title"]. (. $ row ["page_time"].).R>;
Echo $ line;
Printf ("");

}
MySQL (the best combination with PHP) _ free_result ($ result );
?>

 

MySQL (the best combination with PHP) _ close ($ link );
?>

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.