PHP solves an endless loop caused by compressed code

Source: Internet
Author: User
Requirements for idstr1str21saabbb2saabbc3sss123 in the testtable1 table: list the content of & ldquo; str1 & rdquo; segments without duplicates. It would have been a few simple lines, but I think the code can be compressed, so it looks more concentrated, so the cup is

Test. table1 table
Id Str1 Str2
1 Saa Bbb
2 Saa Bbc
3 Sss 123

Requirement: the content of the "str1" section is not repeated.
It would have been a few simple lines, but I think the code can be compressed, which looks more concentrated, so the Cup will happen. the error code is as follows:
 ";}?>

Do you see the problem at first glance? This product actually triggers an endless loop... T_T

So I restored it step by step, and the endless loop disappeared. Obviously, it is not a problem to submit statements. it should be a problem with the syntax structure.

Sure enough, the problem lies in while. Each time a condition is detected, mysql_query is executed. Then the cup is ready.

The correct code is as follows:

 ";}?>

Code optimization, the first of all evil ...... Calm down, calm down!

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.