Me thinkst you need to put singled quotes around $q{BUTTON}.
my $rows = $dbh->do("DELETE FROM contacts WHERE rowid =\'$q{BUTTON}\'");
You also don't appear to be checking for any error....which you should be
seeing. I don't Perl/DBI well enough to show how to do that one.
Michael D. Black
Senior Scientist
NG Information Systems
Advanced Analytics Directorate
________________________________________
From: [email protected] [[email protected]] on
behalf of John Delacour [[email protected]]
Sent: Friday, January 28, 2011 10:05 AM
To: General Discussion of SQLite Database
Subject: EXTERNAL:[sqlite] Can't delete a row
I thought I was making a bit of progress but I've come up against a
brick wall trying to do what appears to be the most simple thing.
A button pressed in the page to delete a selected record is stripped
of its display name to become simply the rowid.
When I run the statement in the sqlite command line the row is
deleted but I get no result and no deletion from running the routine
below either independently or in the html page. I've tried with
single quotes, double quotes and various other
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;
# JD
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users