这个字后一个字节是“\”,在往数据库中写的时候一直报语法错误做了如下试验:
表格为:
mysql> desc testaa;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| id    | int(11)  | NO   |     | 0       |       | 
| name  | char(64) | YES  |     | NULL    |       | 
+-------+----------+------+-----+---------+-------+perl代码为:
open FP, "test.txt";
my $name = <FP>;
close FP; 
chomp $name;
my $sth = $dbh->prepare("update testaa set name=? where id=?");
$sth->execute($name, 7); 
这个字不能直接写的程序中,语法通不过,说以写到一个单独的文件test.txt中,然后读进来的。错误为:
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '7'' at line 1 at test.pl line 14.即使在execute前调用$dbh->quote()也不能解决问题,报同样的错误请问大家有什么方法能解决这个问题