Can anybody tell me why this insert might not be working.
The first code is from the cgi script the second is from a module.
if ($param{submit} && $param{day} >0 && $param{day} <= $leapdays{$tmp +mon}&& $param{month} > 0 && $param{month} <= 12 && $param{year } > 1920 ) { $id++; #$mysql->Insert("events",$id,$param{day},$param{month},$param{ +year},$param{subject},$param{description},$username); $mysql->Insert("events",$param{day},$param{month},$param{year} +,$param{subject},$param{description},NULL); print "Record Inserterd";
sub Insert { my $self = shift; my $table = shift; my @fields; my @values; my $show_field; foreach (@_) { my ($field_name,$value) = split(/\|/,$_); if (!$value) { $show_field = 1; $_ = &clean_text($_); push (@values,$_); } else { $value = &clean_text($value); push(@fields,$field_name); push(@values,$value); } } my $value = join("\',\'",@values); $value = "\'$value\'"; if ($show_field != 1) { my $field = join(",",@fields); $field = "($field)"; } my $mysql = "INSERT INTO $table $field VALUES ($value)"; #return $mysql; my $sth = $self->_execute($mysql); #my $sth = $self->[0]->prepare($mysql) or die "Prep Error"; #my $rv = $sth->execute or die "Exec Error"; #return $self; }

In reply to Problem with insert using DBI by mnlight

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.