MySQL操作程序十一(支付時(shí)間/判斷是否是數(shù)字,mscqtn_input.pl的price)

返回

[error] [client 127.0.0.1] Use of uninitialized value in split at ./pro/mscqtn_input.pl line 614, 614:@{ $t{pid_list} } = split(/=/,$t{partsid}); ------------------------------------------ [error] [client 127.0.0.1] Use of uninitialized value in concatenation (.) or string at ./pro/mscqtn_input.pl line 698, 698: $t{line1} .= '" value="' . $t{dd1} . '"></td><td>'; 跟enq2 table的discount項(xiàng)目有關(guān)(注意其賦值情況) ------------------------------------------ [error] [client 127.0.0.1] Argument "" isn't numeric in numeric ne (!=) at ./pro/mscqtn_input.pl line 110 110: if ( $t{pl1}[$n] != 0 ) { 修改如下 110: if ( $t{pl1}[$n] ) { 145: if ( $t{pl1}[$n] != 0 ) { 修改如下 145: if ( $t{pl1}[$n] ) { [error] [client 127.0.0.1] Argument "" isn't numeric in numeric ne (!=) at ./pro/mscqtn_input.pl line 581 581: if ( $t{pl1}[$n] != 0 ) { 修改如下 581: if ( $t{pl1}[$n] ) {

mysql> show columns from enq2; +------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | time | date | YES | | NULL | | | enq1id | int(11) | YES | | NULL | | | LANGUAGEid | int(11) | YES | | NULL | | | ORIGINid | int(11) | YES | | NULL | | | PRICEid | int(11) | YES | | NULL | | | PAYMENTid | int(11) | YES | | NULL | | | makerid | int(11) | YES | | NULL | | | DELIVERY | text | YES | | NULL | | | type1id | text | YES | | NULL | | | partsid | text | YES | | NULL | | | QTY | text | YES | | NULL | | | memo | text | YES | | NULL | | | price | text | YES | | NULL | | | discount | text | YES | | NULL | | | discount0 | int(11) | YES | | NULL | | | money | int(11) | YES | | NULL | | | price1 | text | YES | | NULL | | | makerref | text | YES | | NULL | | | disc | text | YES | | NULL | | | charges | text | YES | | NULL | | +------------+---------+------+-----+---------+----------------+ 21 rows in set (0.06 sec)
[Sun Sep 12 12:31:37 2010] [error] [client 127.0.0.1] Argument "C" isn't numeric in numeric ne (!=) at ./pro/mscqtn_input.pl line 568, <CONFIG> line 11., referer: http://localhost/cgi-bin/msc_start.cgi [Sun Sep 12 12:31:37 2010] [error] [client 127.0.0.1] Argument "" isn't numeric in addition (+) at ./pro/mscqtn_input.pl line 430, <CONFIG> line 11., referer: http://localhost/cgi-bin/msc_start.cgi 430: $t{total} = $$pref{total}+$t{charges}+$t{disc}; 修改如下: if ($t{e2}[19]) { $t{disc} = $t{e2}[19]; } else { $t{disc} = 0; } $t{pl2} = 0; @{ $t{pl1} } = split(/=/,$t{partsid}); for $n ( 0 .. $#{ $t{pl1} } ) { 568: if ( $t{pl1}[$n] != 0 ) { $t{pl2}++; } }

相同code時(shí)的價(jià)格輸入問題


checkbox的checked

# mscqtn_input.pl $t{enq1_select} = 'enq1_select'; ##------挑選全部零件 } elsif ( $t{pat} eq 'selectall' ) { $t{enq1_select} = 'enq1_selectall'; } # 顯示對(duì)應(yīng)enq1的所有零件供挑選 $$pref{mode} = $t{enq1_select}; # mscenq1.pl } elsif ( $$pref{mode} eq 'enq1_select' ) { $t{check1} = 'c_t' . $t{type1id} . '_d' . $t{dwg1} . '_p' . $t{pid1}; $t{line1} .= '<INPUT TYPE="checkbox" NAME="'; $t{line1} .= $t{check1} . '">' . $t{check1} . '</td><td>'; } elsif ( $$pref{mode} eq 'enq1_selectall' ) { # 增加的部分 $t{check1} = 'c_t' . $t{type1id} . '_d' . $t{dwg1} . '_p' . $t{pid1}; $t{line1} .= '<INPUT TYPE="checkbox" checked NAME="'; $t{line1} .= $t{check1} . '">' . $t{check1} . '</td><td>'; }
use strict; my(%t,$valid,$val,$n); $t{list}[0] = '22'; $t{list}[1] = '1.22.3'; $t{list}[2] = '私22.'; $t{list}[3] = '22.3私'; $t{list}[4] = '1.223'; for $n ( 0 .. $#{ $t{list} } ) { $val = $t{list}[$n]; $valid = is_price($val); if ( $valid ) { print "$val is OK,$valid\n"; } else { print "$val is NOT OK!$valid\n"; } } sub is_price { my $s = shift; my $data; $data = 0; if ( $s =~ /^\+?(\d+)/ ) { $data = $1; } if ( $s =~ /^\+?(\d+\.\d+)/ ) { $data = $1; } if ( $s =~ /^\+?\d+\.\d+\./ ) { $data = 0; } return ( $data );; } 22 is OK,22 1.22.3 is NOT OK!0 私22. is NOT OK!0 22.3私 is OK,22.3 1.223 is OK,1.223 use strict; my(%t,$valid,$val,$n); $t{list}[0] = '22'; $t{list}[1] = '1.22.3'; $t{list}[2] = '私22.'; $t{list}[3] = '22.3私'; for $n ( 0 .. $#{ $t{list} } ) { $val = $t{list}[$n]; $valid = is_price($val); if ( $valid ) { print "$val is OK,$valid\n"; } else { print "$val is NOT OK!$valid\n"; } } sub is_price { my $s = shift; my $data; $data = 0; if ( $s =~ /^\+?(\d+)/ ) { $data = $1; } if ( $s =~ /^\+?(\d+\.\d+)/ ) { $data = $1; } return ( $data );; } 22 is OK,22 1.22.3 is OK,1.22 私22. is NOT OK!0 22.3私 is OK,22.3
# 判定一個(gè)數(shù)字 sub is_number { my $s = shift; return ( ($s =~ /^\+?\d+$/ or $s =~ /^\+?\d+\.\d*$/ ) && $s > 0 ); } #---------輸入價(jià)格 } elsif ( $t{pat} eq 'price' ) { # 貨幣單位 $t{money1} = $t{q}->param("money1"); $t{sql} = 'UPDATE enq2 set money = "'; $t{sql} .= $t{money1} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); # 輸入內(nèi)容 $t{partsprice} = $t{q}->param("partsprice"); @{ $t{prices} } = split(/\r\n/,$t{partsprice}); $t{valids} = -1; for $n ( 0 .. $#{ $t{prices} } ) { $t{prices_test} = $t{prices}[$n]; $t{valid1} = is_number($t{prices_test}); if ( $t{valid1} == 1 ) { $t{valids}++; } } if ( $t{valids} == $#{ $t{prices} } ) { $t{valid} = 1; } else { $t{valid} = 0; } if ( $t{valid} == 0 ) { $t{price_input} = '輸入價(jià)格中含有非數(shù)字符號(hào)。檢查后重新輸入。'; } else { $t{prices_length} = $#{ $t{prices} } + 1; # 取得主機(jī)和零件 ($t{type1id},$t{partsid}) = $self->dbh->selectrow_array("SELECT type1id,partsid FROM enq2 WHERE id = $t{enq2_id}"); # 取得零件數(shù)量 $t{pl2} = 0; @{ $t{pl1} } = split(/=/,$t{partsid}); for $n ( 0 .. $#{ $t{pl1} } ) { if ( $t{pl1}[$n] ) { $t{pl2}++; } } if ( $t{prices_length} != $t{pl2} ) { $t{price_input} = '輸入價(jià)格的數(shù)量與零件數(shù)量不符。檢查后重新輸入。'; } else { $t{price_input} = '輸入價(jià)格成功!'; # enq2に書き込む $t{price} = join('=',@{ $t{prices} }); $t{sql} = 'UPDATE enq2 set price ="'; $t{sql} .= $t{price} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); # 時(shí)間を更新 # 取得時(shí)間 $a_ref = obtain_time($a_ref); $t{time1} = $$a_ref{time1}; $t{sql} = 'UPDATE enq2 set time ="'; $t{sql} .= $t{time1} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); } }
# test_inputdata.pl use strict; my(%t,$valid,$val,$n); @{ $t{list} } = qw/33 -33 '33' 33.3 33.444 33. 34.0/; for $n ( 0 .. $#{ $t{list} } ) { $val = $t{list}[$n]; $valid = is_price($val); if ( $valid ) { print "$val is OK\n"; } else { print "$val is NOT OK!\n"; } } sub is_price { my $s = shift; return ( ($s =~ /^\+?\d+$/ or $s =~ /^\+?\d+\.\d*$/ ) && $s > 0 ); } 運(yùn)行結(jié)果 33 is OK -33 is NOT OK! '33' is NOT OK! 33.3 is OK 33.444 is OK 33. is OK 34.0 is OK
$valid = is_number($input_data); sub is_number { my $s = shift; return( $s =~ /^\+?\d+$/ ); } #---------輸入價(jià)格 } elsif ( $t{pat} eq 'price' ) { # 貨幣單位 $t{money1} = $t{q}->param("money1"); $t{sql} = 'UPDATE enq2 set money = "'; $t{sql} .= $t{money1} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); # 輸入內(nèi)容 $t{partsprice} = $t{q}->param("partsprice"); @{ $t{prices} } = split(/\r\n/,$t{partsprice}); $t{prices_test} = join('',@{ $t{prices} }); $t{valid} = is_number($t{prices_test}); if ( $t{valid} == 0 ) { $t{price_input} = '輸入價(jià)格中含有非數(shù)字符號(hào)。檢查后重新輸入。'; } else { $t{prices_length} = $#{ $t{prices} } + 1; # 取得主機(jī)和零件 ($t{type1id},$t{partsid}) = $self->dbh->selectrow_array("SELECT type1id,partsid FROM enq2 WHERE id = $t{enq2_id}"); # 取得零件數(shù)量 $t{pl2} = 0; @{ $t{pl1} } = split(/=/,$t{partsid}); for $n ( 0 .. $#{ $t{pl1} } ) { if ( $t{pl1}[$n] ) { $t{pl2}++; } } if ( $t{prices_length} != $t{pl2} ) { $t{price_input} = '輸入價(jià)格的數(shù)量與零件數(shù)量不符。檢查后重新輸入。'; } else { $t{price_input} = '輸入價(jià)格成功!'; # enq2に書き込む $t{price} = join('=',@{ $t{prices} }); $t{sql} = 'UPDATE enq2 set price ="'; $t{sql} .= $t{price} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); # 時(shí)間を更新 # 取得時(shí)間 $a_ref = obtain_time($a_ref); $t{time1} = $$a_ref{time1}; $t{sql} = 'UPDATE enq2 set time ="'; $t{sql} .= $t{time1} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); } }
返回
同心县| 荔波县| 彰化市| 萨迦县| 临湘市| 德钦县| 汪清县| 双鸭山市| 富阳市| 阿巴嘎旗| 河津市| 台州市| 无极县| 吴桥县| 庄浪县| 沂源县| 汾西县| 湟中县| 新密市| 准格尔旗| 张掖市| 南京市| 万盛区| 前郭尔| 沁阳市| 高碑店市| 潍坊市| 荔波县| 峨边| 普陀区| 舞阳县| 桂阳县| 惠东县| 贵德县| 东丽区| 望奎县| 建昌县| 福州市| 丰城市| 北票市| 交城县|