Home >Database >Mysql Tutorial >mysql1064错误原因及解决办法_MySQL

mysql1064错误原因及解决办法_MySQL

WBOY
WBOYOriginal
2016-06-01 13:17:212556browse

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中的语句改为使用双引号““”,至此问题得以解决。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn