> Hi all, > > I have a web page I am working on to delete an entry out of a database. If I take the syntax in the perl script and paste it into a mysql query, and substitute the variable for a value that exists in the database, it will delete the entry. If I run it thru the web page, I dont get an error, it says it worked ok and I get no errors. The remove subroutine calls the removemac subroutine. Here is the code: >
You didn't really state what the problem is, I assume the entry is not actually deleted? Generally when we get no errors we are happy :-). > --- CODE --- > > sub remove { > my $delmac; > What is $delmac doing? Where does $self below come from? I suspect you have broken encapsulation, which can be on purpose (I suppose). > print "<h3 align=center> Delete MAC </h3>"; > > print "<h4 align=center> Careful! Make sure you know what you are doing! > </h4>"; > > return <<FRM; > <center> > <form action="$self" method="post"> > <input type="hidden" name="action" value="removemac"> > MAC Address to remove: <input type="text" name="delmac"> > <input type="submit" value="Delete MAC"> > </form> > </center> > FRM > You said in your description that 'remove' calls 'removemac'... why? and more importantly *where*?? > } > > sub removemac { > my $user = param('delmac'); > > print $user; > > my $query = "DELETE FROM passwd WHERE user_name=$user LIMIT 1"; Many DBs require you to quote non-integer values, is $user an integer value, you have asked for MAC addresses (are there colons in the value?). The above is better written using DBI's binding capability. Switch C<$user> to C<?> and add $user as an argument to C<execute> below. > > my $sth = $dbh->prepare($query) || &db_err("Cannot prepare $query <P> \n > :" . $dbh->errstr . "\n"); > > $sth->execute || &db_err("Cannot execute $query <P> \n:" . $dbh->errstr > . "\n"); > > $sth->finish; > > print "<h3 align=center> Deleted customer! </h3>"; > Not necessarily, as you are finding. You should probably check that a row has been deleted. > print "<center<a href\"" . $self . "?action=\"> Go Back </a>"; > > } > > --- CODE --- > > Any help is appreciated. > > Thanks, > > Dave Kettmann > NetLogic > 636-561-0680 > http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>