MySQL操作程序三十四(mscshow241.pl,mscshowaddowner.pl,mscupdate.pl,msc241_list)

返回

[Mon Apr 16 10:00:08 2012] [error] [client 192.168.116.107] DBD::mysql::db selectrow_array failed: Unknown column 'B' in 'where clause' at ./pro/mscshow241.pl line 59 [Mon Apr 16 10:00:08 2012] [error] [client 192.168.116.107] Use of uninitialized value in join or string at ./pro/mscshow241.pl line 62 for $n ( 0 .. $#{ $t{type1s} } ) { $t{type1s1} = $t{type1s}[$n]; 59: $t{name1} = $self->dbh->selectrow_array("SELECT name FROM main_type1 WHERE id = $t{type1s1}"); 60: push(@{ $t{type1} },$t{name1}); 61: } 62: $t{type1_list} = join('<br>',@{ $t{type1} }); 解决方法: 当type1s1是'B'的时候,不去读main_type1表
<!-- ENQ --> <form action="" method="post"> <input type="submit" value="ENQ"><p> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="pat" value="NO"> <input type="hidden" name="rm" value="modeenq1"> </form> ===> <form action="" method="post"> <input type="submit" value="<TMPL_VAR NAME="ourref">"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="pat" value="NO"> <input type="hidden" name="rm" value="modeenq1"> </form> -------------------------------------------------------------------------- HTML::Template : Attempt to set nonexistent parameter 'name1' - this parameter name doesn't match any declarations in the template file : (die_on_bad_params => 1) at ./pro/mscshowone.pl line 41 ==>msc242.htm忘了修改 mysql> ALTER TABLE owners CHANGE name name1 char(100); Query OK, 331 rows affected (1.39 sec) Records: 331 Duplicates: 0 Warnings: 0 mysql> show columns from owners; +----------+-----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-----------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | company | char(100) | YES | | NULL | | | name1 | char(100) | YES | | NULL | | | address | char(100) | YES | | NULL | | | person | char(50) | YES | | NULL | | | telfax | char(100) | YES | | NULL | | | email | char(100) | YES | | NULL | | | homepage | char(100) | YES | | NULL | | | memo | char(100) | YES | | NULL | | +----------+-----------+------+-----+---------+----------------+ 9 rows in set (0.01 sec) mysql> show columns from hull_no; +---------+-----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+-----------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | HULL_NO | char(50) | YES | | NULL | | | name | char(50) | YES | | NULL | | | built | date | YES | | NULL | | | flag | char(50) | YES | | NULL | | | memo | char(100) | YES | | NULL | | +---------+-----------+------+-----+---------+----------------+ 6 rows in set (0.13 sec) mysql> show columns from owners; +----------+-----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-----------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | company | char(100) | YES | | NULL | | | name | char(100) | YES | | NULL | | | address | char(100) | YES | | NULL | | | person | char(50) | YES | | NULL | | | telfax | char(100) | YES | | NULL | | | email | char(100) | YES | | NULL | | | homepage | char(100) | YES | | NULL | | | memo | char(100) | YES | | NULL | | +----------+-----------+------+-----+---------+----------------+ 9 rows in set (0.09 sec) mscupdate.pl # 入力したname if ( $arr[1] eq 'name' && $t{table} ne "main_type1" ) { $t{name1} = $t{q}->param($arr[1]); # すべてのnameを取り出す $aref = $self->dbh->selectcol_arrayref("SELECT name FROM $t{table}"); @{ $$a_ref{list} } = @$aref; $$a_ref{name1} = $t{name1}; ($a_ref) = check1($a_ref); if ( $$a_ref{NG} == 1 ) { $t{template} = $self->load_tmpl("$t{html2}") || die "error loading tmpl"; $t{template}->param(id => $t{id}); for $n ( 0 .. $#arr ) { $t{name} = $arr[$n]; $t{value} = $arr1[$n]; $t{template}->param($t{name} => $t{value}); } return $t{template}->output; }
[Sun Sep 12 22:40:55 2010] [error] [client 127.0.0.1] DBD::mysql::db selectrow_array failed: Unknown column 'B' in 'where clause' at ./pro/mscshow241.pl line 59, <CONFIG> line 11., referer: 修改思路(此类程序需要考虑$t{type1s1}不是整数的情况) for $n ( 0 .. $#{ $t{type1s} } ) { $t{type1s1} = $t{type1s}[$n]; 59: $t{name1} = $self->dbh->selectrow_array("SELECT name FROM main_type1 WHERE id = $t{type1s1}"); push(@{ $t{type1} },$t{name1}); }
返回