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?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章