【发布时间】:2013-11-29 06:14:11
【问题描述】:
我们有一个旧应用程序在使用 Perl-5.8.5.8 时运行良好,但在 Perl-5.8.8 上不再运行,我确信这是一个简单的更改,但我找不到它。
DBD::mysql::st execute failed: Unknown column 'stores.id' in 'on clause' at /var/www/cgi-bin/app/list.cgi line 70
这是第 70 行的上下文
my $sth=$dbh->prepare($sql);
$sth->execute(); ################Line 70
这是完整的程序
#!/usr/bin/perl
do "share.pl";
sub get_propertytable {
my ($id, $devicename) = @_;
my $content = "<table><tr><th colspan=2>$devicename $id</th></tr>";
my $sql = "SELECT propertytypes.propertyname, deviceproperties.propertyvalue FROM deviceproperties INNER JOIN propertytypes ON deviceproperties.propertytype = propertytyp$
my $sthq = $dbh->prepare($sql);
$sthq->execute();
$sthq->bind_columns(\$propname, \$propvalue);
while ($sthq->fetch()){
if ($propname !~ /"Connected"/){
$content .= "<tr><td>$propname</td><td>: $propvalue</td></tr>";}
}
$content .= "</table>";
}
sub get_storetable {
my $id = @_[0];
my $content = "<table><tr><th colspan=2>Store $id</th></tr>";
my $sql = "SELECT storename,address,postcode,phoneno FROM stores WHERE id=$id";
my $sthq = $dbh->prepare($sql);
$sthq->execute();
my ($storename, $address, $postcode, $phoneno);
$sthq->bind_columns(\$storename, \$address, \$postcode, \$phoneno);
$sthq->fetch();
$address =~ s/,/<br>/g;
my $content = "<table><tr><th colspan=2>$storename</th></tr>";
$content .= "<tr><td valign=top>Address :</td><td>$address</td></tr>";
$content .= "<tr><td>Post Code :</td><td>$postcode</td></tr>";
$content .= "<tr><td>Phone No :</td><td>$phoneno</td></tr>";
$content .= "</table>";
}
sub get_franchisetable {
my $id = @_[0];
if ($id){
my $content = "<table><tr><th colspan=2>Franchise $id</th></tr>";
my $sql = "SELECT contactname,company,contactno,email FROM Franchisees WHERE id=$id";
my $sthq = $dbh->prepare($sql);
$sthq->execute();
my ($contactname, $company, $contactno, $email);
$sthq->bind_columns(\$contactname, \$company, \$contactno, \$email);
$sthq->fetch();
$address =~ s/,/<br>/g;
my $content = "<table><tr><th colspan=2>$company</th></tr>";
$content .= "<tr><td valign=top>Contact Name :</td><td>$contactname</td></tr>";
$content .= "<tr><td>Contact No :</td><td>$contactno</td></tr>";
$content .= "<tr><td>Email :</td><td>$email</td></tr>";
$content .= "</table>";
}
}
if ( valid_user() == 1 ) {
my $sql = "SELECT id,devicename FROM devicetypes";
my $sth=$dbh->prepare($sql);
$sth->execute();
$sth->bind_columns(\$id, \$devicename);
while ($sth->fetch()){
$devicetypes[$id] = $devicename;
}
$sth->finish();
my $sql = "SELECT stores.id, stores.storename, devices.id,devices.devicetype,tradingpartner.name,tradingpartner.id
FROM stores,storetradingpartner,tradingpartner
LEFT JOIN devices ON devices.store = stores.id
WHERE stores.id = storetradingpartner.storeid
AND tradingpartner.id = storetradingpartner.partnerid
ORDER BY tradingpartner.name,stores.storename,devices.devicetype,devices.id";
my $sth=$dbh->prepare($sql);
$sth->execute(); ################# Line 70
#$sth->bind_columns(\$storeid, \$store, \$deviceid, \$devicetype, \$tradingpartner, \$partnerid);
print "Content-type: text/html
<body link='#000000' vlink='#000000' alink='#000000'>
<script type=\"text/javascript\" src=\"/clit/wz_tooltip.js\" language='javascript'>
</script>
<SCRIPT SRC=\"/clit/getpropertytable.js\">
</SCRIPT>
<script language='javascript' type=\"text/javascript\">
function hidediv(thediv) {
if (document.getElementById(thediv).style.display == 'none'){
document.getElementById(thediv).style.display = 'block';
} else {
document.getElementById(thediv).style.display = 'none';
}
return 0;
}
//</script>
<font face=arial>
<h1>Asset List</h1>
<a href=index.cgi>Back to ticket list</a>
<br><br>
【问题讨论】:
-
错误消息暗示您的架构不匹配。除了更改 Perl 版本之外,您是否已移至另一台机器,或重建了数据库?
-
我害怕 Perl 5.8.8 被认为是升级的世界。
-
编写一个简单的 perl 来使用 DBI 并确保它可以工作
-
没有
Perl 5.8.5.8。您的意思是将5.8.5升级到5.8.8(即2004 年7 月至2006 年1 月)? -
感谢大家的指点和帮助,备注...