mysql 1064错误原因及解决办法 1064错误意思是说我的sql语法错误,然后显示错误的具体位置。 查看待更新的内容,以及执行跟新的php语句。 php语句如下: if(!$handle= @fopen($fname, r)) {echo open $fname failedn;exit;}; $str=;$count=0;$ins=insert int
mysql 1064错误原因及解决办法1064错误意思是说我的sql语法错误,然后显示错误的具体位置。
查看待更新的内容,以及执行跟新的php语句。
php语句如下:
if(!$handle= @fopen($fname, "r")) {echo "open $fname failedn";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 failedn";
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中的语句改为使用双引号““”,至此问题得以解决。
.syntaxhighlighter{padding-top:20px;padding-bottom:20px;}【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!