MySQL 1064錯誤原因及解決辦法

來源:互聯網
上載者:User

MySQL 1064錯誤意思是說我的SQL語法錯誤,然後顯示錯誤的具體位置。

查看待更新的內容,以及執行跟新的php語句。

php語句如下:

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,'3955')";
 $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);

待跟新的內容如下:

1320#CarryDream Int'l Co., Ltd.
1321#ES APP Group
1322#app4uu

從中可以發現待跟新的內容中還有單引號“‘”,使用的sql語句中列印的欄位也含有單引號,兩者產生了衝突。

所以解決的辦法就是,將sql中的語句改為使用雙引號““”,至此問題得以解決。

MySQL錯誤:ERROR 1064 (42000): use near 'order’解決 

MySQL報錯ERROR 1044 ERROR 1064 (42000):

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.