remluvr has asked for the wisdom of the Perl Monks concerning the following question:
Where am I going wrong? Thanks everyone for the very much needed helpsub framerightsave{ my($dbhsource,$dbhinstance,$dbhadmin,$firstfield,$ynfield,$thirdfi +eld,$save,$op) = @_; my(@inst,@altern,@yn,$curent,$curinst,$curalt,$curyn,$htmld,$n,$sa +vedata); @yn = split(/\|/,$ynfield); @altern = split(/\|/,$thirdfield); @inst = split(/\|/,$firstfield); print "<table border=1 bgcolor=#cbe8fc border=0 cellspacing=0 cell +padding=2 width=100%>"; print "<tr bgcolor=#fce7ca><td colspan=4><font size=-1 face=verdan +a >Save evaluations of instances: $instance</font></td></tr>"; print "<tr bgcolor=#fce7ca><td><font size=-1><b>Istanza</td><td><f +ont size=-1><b>Saved evaluation</td><td><font size=-1><b>Alternative +evaluation</td></tr>"; my $mysqldbinstance=$frameinit::MYSQLDBINS; $dsninstance = "DBI:mysql:database=$mysqldbinstance;host=$myhost"; $dbhinstance = DBI->connect($dsninstance, $mysqluser, $mysqlpwd)|| + print "NON RIESCO A CONNETTERMI\n"; while(@inst){ $curent = shift @inst; $curyn = shift @yn; $curaltern = shift @altern; if($curyn =~ /\w+/){ &updatemysql($curent,$curyn,$curaltern); } print "<tr bgcolor=$col><td><font size=-1><b>$curent</td><td>< +font size=-1><b>$curyn</td><td><font size=-1>$curaltern</td></tr>"; } print "</table>"; } sub updatemysql{ my($curent,$curyn,$curaltern) = @_; my($update,$mysqldbinstance,$dsninstance, $dbhinstance, $sthinstan +ce,$rvinstance,$toupdt); my $mysqldbinstance=$frameinit::MYSQLDBINS; $dsninstance = "DBI:mysql:database=$mysqldbinstance;host=$myhost"; $dbhinstance = DBI->connect($dsninstance, $mysqluser, $mysqlpwd)|| + print "NON RIESCO A CONNETTERMI\n"; if($curyn =~ /yes/){ $toupdt= $curyn; } else{ if ($curaltern =~/\w+/) { $toupdt= $curyn.'_'.$curaltern; } else{ $toupdt= $curyn; } } if($curyn =~ /\w+/){ $update = "update inst_3 set u1 = \"$toupdt\" where object = \ +"$curent\""; $sthinstance = $dbhinstance->prepare($update); $rvinstance = $sthinstance ->execute(); if ( !defined($rvinstance) ){ print "exec:$DBI::errstr, $select\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem updating mysql table
by Gangabass (Vicar) on Dec 28, 2010 at 14:34 UTC | |
by remluvr (Sexton) on Dec 28, 2010 at 15:16 UTC | |
by Corion (Patriarch) on Dec 28, 2010 at 15:24 UTC | |
by remluvr (Sexton) on Dec 28, 2010 at 15:56 UTC |