求助!!
我在学习perl终于都这样一个问题:
$test_string = 1;
use DBI;
my $dbh=DBI->connect("DBI:mysql:passwd","zhao","1119")
|| die "Cannot connect:\n";
$sth=$dbh->prepare('select * from user_password where username=$test_string')
|| die "Cannot prepare:$dbh->errstr\n";
$rc=$sth->execute || die "Cannot execute:$dbh->errstr\n";
这样编译就会有错:DBD::mysql::st execute failed: Unknown column '$test_string' in 'where clause' at test.pl line 14.
而直接改成$sth=$dbh->prepare('select * from user_password where username=1') 就可以查询了.
请教要如何才能在sql语言中引用变量的值($test_string).
谢谢!!