mysql 1064错误原因及解决办法
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 group1322#app4uu
从中可以发现待跟新的内容中还有单引号“‘”,使用的sql语句中打印的字段也含有单引号,两者产生了冲突。
所以解决的办法就是,将sql中的语句改为使用双引号““”,至此问题得以解决。
