Redian新闻
>
Perl插入MySQL中双引号的问题
avatar
Perl插入MySQL中双引号的问题# Programming - 葵花宝典
L*r
1
用如下语句给MySQL插值,当$words[0]= " 的时候,perl脚本出错:
比如这行数据: ! ) " 60252
my $rows = $dbh->do(qq{INSERT INTO GoogleDVD_all (word_0,word_1,word_2,N1)
VALUES ("$words[0]","$words[1]","$words[2]","$words[3]")});
DBD::mysql::db do 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 '60252")' at line 1 at delimiter_changer4.pl line 15, line
31.
请赐教,谢谢
avatar
c*t
2
用单引号

to
line

【在 L******r 的大作中提到】
: 用如下语句给MySQL插值,当$words[0]= " 的时候,perl脚本出错:
: 比如这行数据: ! ) " 60252
: my $rows = $dbh->do(qq{INSERT INTO GoogleDVD_all (word_0,word_1,word_2,N1)
: VALUES ("$words[0]","$words[1]","$words[2]","$words[3]")});
: DBD::mysql::db do 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 '60252")' at line 1 at delimiter_changer4.pl line 15, line
: 31.
: 请赐教,谢谢

avatar
l*9
3
you need place-holder
my $rows = $dbh->do(qq{INSERT INTO GoogleDVD_all (word_0,word_1,word_2,N1)
VALUES (?,?,?,?)}, @words[0,1,2,3]);
(untested)..
recommend you "use DBIx::Simple" which makes DBI interface much easier..

to
line

【在 L******r 的大作中提到】
: 用如下语句给MySQL插值,当$words[0]= " 的时候,perl脚本出错:
: 比如这行数据: ! ) " 60252
: my $rows = $dbh->do(qq{INSERT INTO GoogleDVD_all (word_0,word_1,word_2,N1)
: VALUES ("$words[0]","$words[1]","$words[2]","$words[3]")});
: DBD::mysql::db do 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 '60252")' at line 1 at delimiter_changer4.pl line 15, line
: 31.
: 请赐教,谢谢

avatar
L*r
4
谢谢,还有问题
在插入如下行时出错:
$ ' 1550166
DBD::mysql::db do 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 '1550166')' at line 1 at delimiter_changer5.pl line 19,
line 10000000.
$ '0 13616
DBD::mysql::db do 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 '0','13616')' at line 1 at delimiter_changer5.pl line

【在 l*******9 的大作中提到】
: you need place-holder
: my $rows = $dbh->do(qq{INSERT INTO GoogleDVD_all (word_0,word_1,word_2,N1)
: VALUES (?,?,?,?)}, @words[0,1,2,3]);
: (untested)..
: recommend you "use DBIx::Simple" which makes DBI interface much easier..
:
: to
: line

avatar
L*r
5
DBI::db=HASH(0x812d770)->do(...): attribute parameter '!' is not a hash ref
at delimiter_changer4.pl line 17, line 31.

N1)
the
syntax

【在 l*******9 的大作中提到】
: you need place-holder
: my $rows = $dbh->do(qq{INSERT INTO GoogleDVD_all (word_0,word_1,word_2,N1)
: VALUES (?,?,?,?)}, @words[0,1,2,3]);
: (untested)..
: recommend you "use DBIx::Simple" which makes DBI interface much easier..
:
: to
: line

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。