At 09:26 AM 3/28/2003 +0000, Rob Anderson wrote:
Jaws,
This looks like your script is working fine, but the insert your trying to do is in error. I'd guess that your just trying to add a row with a duplicate key, and that's what DBI is complaining about, because of a contraint on the database. You could try different keys, or the INSERT statement from somewhere else (SQLPLUS?) to see if you get the same error.
Hope this helps.
Rob
"Jaws" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > when i run the program like this: > > [EMAIL PROTECTED] util]# ./addvpdnuser.pl > sampleusername, samplepassword,sampledescription,sampleattr > > DBD::mysql::st execute failed: Duplicate entry 'sample' for key 1 at > ./addvpdnuser.pl line 17, <> line 1. > DBD::mysql::st execute failed: Duplicate entry 'sample' for key 1 at > ./addvpdnuser.pl line 17, <> line 1. > [EMAIL PROTECTED] util]# > > That's the error message of the program. > > > At 08:54 AM 3/28/2003 +0000, Rob Anderson wrote: > >Hi Jaws (!?), > > > >You don't say where your script is failing, or what errors it's reporting, > >which is going to make it hard for anyone to help. You could add some better > >error checking. Here's a couple of lines lifted from one of my CGI's. > > > >my $dbh; > >eval { $dbh = DBI->connect( $DATA_SOURCE, $DB_USER, $DB_PASSWORD, { > >RaiseError => 1, AutoCommit => 1 } ) }; > > > >if ($@) { > > print "Failed in connecting to database, see following error<br/>\n"; > > print $@ . "<br/>\n"; > > return; > >} > > > >Perhaps you could add something like this to your script to get a better > >idea of what's not working. You can put this type of error checking around > >your compare and execute statements as well. > > > >Good Luck > > > >Rob > > > > > > > >"Jaws" <[EMAIL PROTECTED]> wrote in message > >news:[EMAIL PROTECTED] > > > Hi all, > > > > > > i am new to perl and i want to use it with DBI:mysql module. I want to > > > connect to my sql server and do some data manipulation like , insert, > > > update and delete. I read the DBI documention but i cant get through to > >get > > > my script working. any help is needed. below is my script. > > > > > > #!/usr/bin/perl > > > > > > use DBI; > > > > > > $database="sampledb"; > > > $host="localhost"; > > > $user="db"; > > > $pw="mysql"; > > > > > > $dbh=DBI->connect("DBI:mysql:database=$database;host=$host",$user,$pw, > > > {RaiseError => 1}); > > > > > > my $sth = $dbh->prepare(q{INSERT INTO USERS > > > (USERNAME,PASSWORD,DESCRIPTION,ATTRIBUTES) VALUES (?, ?, ?, ?) > > > }) or die $dbh->errstr; > > > while (<>) { > > > chomp; > > > my ($USERNAME,$PASSWORD,$DESCRIPTION,$ATTRIBUTE) = split > >/,/; > > > $sth->execute($USERNAME,$PASSWORD,$DESCRIPTION,$ATTRIBUTE) > >or > > > die $dbh->errstr; > > > } > > > $dbh->commit or die $dbh->errstr; > > > $dbh->disconnect; > > > > > > > > > -------------- > > > > > > Thanks. > > > > > > Jaws > > > > > > > > > > > > > > > > >-- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------- > cheers, > jaws > > If there's one thing you need to remember it's this... > ALL SYSTEMS ARE VULNERABLE! > > >
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------- cheers, jaws
If there's one thing you need to remember it's this... ALL SYSTEMS ARE VULNERABLE!
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]