Mysql1064 error cause and Solution

Source: Internet
Author: User

The 1064 error indicates that My SQL syntax is incorrect and the specific location of the error is displayed.

View the content to be updated and execute new php statements.

The php statement is as follows:

If (! $ Handle = @ fopen ($ fname, "r") {echo "open $ fname failed \ n"; exit ;}; $ str = ""; $ count = 0; $ ins = "insert into pydot_g (id, aauthor) VALUES"; while ($ buf = fgets ($ handle, 1000 ))! = False) {list ($ id, $ field) = explode ("#", $ buf); $ str. = sprintf ('(% d,' % s'), ', $ id, $ field); $ count ++;} $ str. = "(3955, '000000')"; $ dup = "on duplicate key update aauthor = VALUES (aauthor);"; $ SQL = $ ins. $ str. $ dup; // echo $ SQL. "\ n"; if (! Mysql_query ($ SQL) {echo "mysql failed \ n"; echo mysql_errno (). ":". mysql_error (). "\ n" ;}fclose ($ handle); mysql_close ($ link );

The content to be updated is as follows:

1320 # CarryDream Int 'l Co., Ltd.1321 # es app Group1322 # app4uu
It can be found that there are still single quotation marks (') in the content to be followed, and the fields printed in the SQL statement also contain single quotation marks, which conflict with each other.

So the solution is to change the SQL statement to the double quotation mark "", so this problem can be solved.

Related Article

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.