Black, Michael (IS) wrote: > Can someone please tell me what I'm doing wrong? > > > #!/usr/local/bin/perl > use strict; > use DBI qw(:sql_types); > my $database = "/Library/webserver/data/iceman.iceman"; > my $dbh = DBI->connect("dbi:SQLite:dbname=$database","","", { > RaiseError => 1, AutoCommit => 1 }) || > print "<p>Cannot connect: $DBI::errstr</p>\n"; > > my %q; > $q{BUTTON} = "Delete c10"; > $q{BUTTON} =~ s~^Delete[^\d]+~~i; > if ($q{BUTTON} =~ s~^Delete[^\d]+~~i){ > my $rows = $dbh->do("DELETE FROM contacts WHERE rowid =$q{BUTTON}"); > print $rows; > } > $dbh->disconnect; >
Can't really say what you are doing wrong, but you code is needlessly complicated; all those tildes are making my eyes swim. I would do the following my $q = "Delete c10"; $q =~ s/(\d+)//; my $sth = $dbh->prepare('DELETE FROM contacts WHERE rowid = ?'); my $rows_affected = $sth->execute($q); -- Puneet Kishor _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users