Eagle_f90 has asked for the wisdom of the Perl Monks concerning the following question:
This is the full code I use. Can anyone tell me what I am doing wrong?$sth = $dbh -> prepare (qq~select ? from FanRatings where Title = +?~) or die $DBI::errstr; $sth -> execute ($rating, $filename) or die $DBI::errstr; @OldRating = $sth -> fetchrow_array;
#!/user/perl use CGI q~:standard~; use CGI::Cookie; use CGI::Carp qw(fatalsToBrowser); use strict; use DBI; my ($dbh, $sth, $filename, $rating, @current, @VotedOn, %cookies, $Can +Vote, $value, $c, @OldRating, $result); $filename = param('name'); $rating = param('rating'); %cookies = fetch CGI::Cookie; $CanVote = 1; if (exists($cookies{'FFInfoVotedOn'})) { @VotedOn = $cookies{'FFInfoVotedOn'} -> value; foreach $value (@VotedOn) { if ($value eq $filename) { $CanVote = 0; } } } $dbh = DBI -> connect ('dbi:ODBC:', '', '') or die $DBI::errstr; if ($CanVote) { $result = 1; $sth = $dbh -> prepare (qq~select One, Two, Three, Four, Five from + FanRatings where Title = ?~) or die $DBI::errstr; $sth -> execute ($filename) or die $DBI::errstr; @current = $sth -> fetchrow_array; if (!defined $current[0]) { $sth = $dbh -> prepare (qq~insert FanRatings (Title, One, Two, + Three, Four, Five) values (?, 0, 0, 0, 0, 0)~) or die $DBI::errstr; $sth -> execute ($filename) or die $DBI::errstr; } $sth = $dbh -> prepare (qq~select ? from FanRatings where Title = +?~) or die $DBI::errstr; $sth -> execute ($rating, $filename) or die $DBI::errstr; @OldRating = $sth -> fetchrow_array; $OldRating[0]++; $sth = $dbh -> prepare (qq~update FanRatings set ? = ? where Title + = ?~) or die $DBI::errstr; $sth -> execute ($rating, $OldRating[0], $filename) or die $DBI::e +rrstr; @VotedOn = (@VotedOn, $filename); $c = new CGI::Cookie(-name => 'FFInfoVotedOn', -value => "@VotedOn", -expires => '+10Y', ); } $dbh -> disconnect;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Variable is filled with column name not data, can't figure out why.
by grep (Monsignor) on Jul 17, 2007 at 03:20 UTC | |
by Eagle_f90 (Acolyte) on Jul 17, 2007 at 23:02 UTC |