"Generalerror: 2050" error occurred when querying MySQL in php.

Source: Internet
Author: User
The ldquo; Generalerror: 2050 rdquo; error occurred when querying mysql in php today. Then ray gave the link, and the problem was solved. As mentioned in the article

The ldquo; General error: 2050 rdquo; error occurred when querying mysql in php today. Then ray gave the link, and the problem was solved. As mentioned in the article

Today, when querying mysql in php, there was a "General error: 2050" error. Later ray gave the link and the problem was fixed.

The article has already been quite clear, and we will directly reference it below:
------------------------------------------
After I upgraded PHP to version 5.2.5, the previously written PDO program always reported the error SQLSTATE [HY000]: General error: 2053. I checked it for a long time before finding a solution to the problem. This problem only occurs when two SQL statements are consecutively requested. The following example shows the problem:


$ S = $ db-> query ("SELECT * FROM test order by poledrugie;"); var_dump ($ s-> fetchAll ()); $ s = $ db-> query ("SELECT * FROM test order by poletrzecie;"); var_dump ($ s-> fetchAll ());

In this case, an error is reported. There are two ways to modify:
1. Replace the handle of the second SQL statement with $ s1.

$ S = $ db-> query ("SELECT * FROM test order by poledrugie;"); var_dump ($ s-> fetchAll ()); $ s1 = $ db-> query ("SELECT * FROM test order by poletrzecie;"); var_dump ($ s1-> fetchAll ());

2. Before the second SQK, clear $ s.
$ S = $ db-> query ("SELECT * FROM test order by poledrugie;"); var_dump ($ s-> fetchAll (); $ s = ''; $ s = $ db-> query ("SELECT * FROM test order by poletrzecie;"); var_dump ($ s-> fetchAll ());

In fact, we can draw a conclusion that if two PDO requests are assigned to the same handle, the second handle will not be overwritten. Therefore, we must manually overwrite it once.

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.