DBD::SQLite::db prepare failed: unrecognized token:

问题:

perl INSERT 数据库操作过程中出现: DBD::SQLite::db prepare failed: unrecognized token:

修改前:

$orderInfo = "{orderInfo: $data}";
$stmls = "INSERT INTO strokeOrder(Name,OrderInfo) values('$nameInfo[1]','$orderInfo')";
$sth = $dbh->prepare($stmls);
$rv = $sth->execute() or die $DBI::errstr;

$orderInfo 包含有 31d0 之类的字符

修改后:

$orderInfo = "{orderInfo: $data}";
$stmls = "INSERT INTO strokeOrder(Name,OrderInfo) values(?,?)";
$sth = $dbh->prepare($stmls);
$rv = $sth->execute($nameInfo[1],$orderInfo) or die $DBI::errstr;

参考:

Perl SQL Query Problems: Character Escaping or Encoding?

你可能感兴趣的:(Perl)