Tried adding an if statment to check value but am still erroring out with "Can't call method "value" on an undefined value at vote.pl line 14." line 14 is the if statment.
#!/user/perl use CGI q~:standard~; use CGI::Cookie; use CGI::Carp qw(fatalsToBrowser); use strict; use DBI; print "Content-type: text/html\n\n"; my ($dbh, $sth, $filename, $rating, @current, @VotedOn, %cookies, $Can +Vote, $value, $c); $filename = param('name'); $rating = param('rating'); %cookies = fetch CGI::Cookie; $CanVote = 1; @VotedOn = ''; if ($cookies{'FFInfoVotedOn'} -> value) { @VotedOn = $cookies{'FFInfoVotedOn'} -> value; foreach $value (@VotedOn) { if ($value eq $filename) { $CanVote = 0; } } } if ($CanVote) { $dbh = DBI -> connect ('dbi:ODBC:FFmisc', '', '') or die $DBI::err +str; $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~update FanRatings set ? = ? + 1 where T +itle = ?~) or die $DBI::errstr; $sth -> execute ($rating, $rating, $filename) or die $DBI::errstr; @VotedOn = (@VotedOn, $filename); $c = new CGI::Cookie(-name => 'FFInfoVotedOn', -value => @VotedOn, -expires => '+10Y', ); print header(-cookie => $c); print qq~Thank you for rating this fan creation.~; } else { print qq~I am sorry but you have alrady rated this fan creation.~; } print qq~<br />You will automaticly be taken back to the page you came + from in 5 seconds.~;

In reply to Re^2: Checking for cookies by Eagle_f90
in thread Checking for cookies by Eagle_f90

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.