#!/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;
}
每当我执行程序时,我都没有得到正确的输出并且代码执行成功
请帮帮我。
答案 0 :(得分: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);