-1
#!/usr/bin/perl

use DBI;
$a="test";

$DSN = q/dbi:ODBC:SQLSERVER/;
$uid = q/ivr/;
$pwd = q/ivr/;

$DRIVER = "Freetds";
$dbh = DBI->connect($DSN,$uid,$pwd) or die "Coudn't Connect SQL";

$sql_query1 = "select top(1) * from winast_sms_template where sms_tmp_service_id =1 and sms_tmp_name like '\%$a'";

$sql_address = $dbh->prepare($sql_query1);
$sql_address->execute();

while ((@city_address)=$sql_address->fetchrow_array())
       {
       $b = $city_address[2];
       print $b;
       }

每当我执行程序时,我都没有得到正确的输出并且代码成功执行

请帮我。

4

1 回答 1

2

尝试这个:

$sql_query1 = "select top(1) * from winast_sms_template where sms_tmp_service_id =1 and sms_tmp_name like ?";

$sql_address = $dbh->prepare($sql_query1);
$sql_address->execute('%' . $a);
于 2012-12-27T19:46:11.523 回答