MySQL Select error

Source: Internet
Author: User

Code snippet:

     " SELECT * from webpage where url = '%s ' " % b          try:         cursor.execute (Sql_url)         = Cursor.fetchall ()     except  Exception, E:         print  E          Pass


System: CentOS

Language: Python

Error message:

" You have a error in your SQL syntax; check the manual, corresponds to your MySQL server version for the right SYN tax-to-use-near "on line 1")

The error message says there is a syntax bug near ' "',

But most of the data ran smoothly, and then I printed out the data at the wrong time and found that the URL was followed by xxx= ' xxxxxxxx '

So plug this URL into the SQL statement and it becomes a select * from webpage where url = ' http://www.baidu.com/index.html?xxx= ' xxxxxxxxx '

Haha, did you see that?

After the single quotation mark of that parameter and the URL after the single quotation mark merge together, originally is 2, the result is 1.

The correct wording is:

' SELECT * from webpage where url = '%s ' ' % b

MySQL Select error

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.