hi ...
So in der Art laufen meine Gedanken gerade ...
Script No. 1
#!/usr/bin/perl
use DBI;
use strict;
use CGI;
my $cgi = CGI->new();
print "Content-type: text/plain\n\n";
my $dbh = DBI->connect('DBI:mysql:database=foobar;host=localhost', '', '') || die $dbh->errstr;
my $sth = $dbh->prepare("INSERT INTO customers VALUES (?, ?)") || die $dbh->errstr;
$sth->execute('', 'User') || die $sth->errstr;
WICHTIGE ZEILE
$sth->finish;
HIER VERWENDE ICH $sth UND $dbh NOCHMALS!
$sth = $dbh->prepare("INSERT INTO foobar VALUES (?, ?, ?, ?)") || die $dbh->errstr;
$sth->execute('', 'a', 'b', 'c') || die $sth->errstr;
$sth->finish;
$dbh->disconnect;
=====================================================================================
Script No. 2
#!/usr/bin/perl
use DBI;
use strict;
use CGI;
my $cgi = CGI->new();
print "Content-type: text/plain\n\n";
my $dbh = DBI->connect('DBI:mysql:database=foobar;host=localhost', '', '') || die $dbh->errstr;
my $sth = $dbh->prepare("INSERT INTO customers VALUES (?, ?)") || die $dbh->errstr;
$sth->execute('', 'User') || die $sth->errstr;
## ACHTUNG
HIER IST _KEIN_ $sth->finish MEHR!
## HIER VERWENDE ICH WIEDER DIE SELBEN NAMEN $sth UND $dbh
$sth = $dbh->prepare("INSERT INTO foobar VALUES (?, ?, ?, ?)") || die $dbh->errstr;
$sth->execute('', 'a', 'b', 'c') || die $sth->errstr;
$sth->finish;
$dbh->disconnect;
=====================================================================================
Script No. 3
#!/usr/bin/perl
use DBI;
use strict;
use CGI;
my $cgi = CGI->new();
print "Content-type: text/plain\n\n";
my $dbh = DBI->connect('DBI:mysql:database=foobar;host=localhost', '', '') || die $dbh->errstr;
my $sth = $dbh->prepare("INSERT INTO customers VALUES (?, ?)") || die $dbh->errstr;
$sth->execute('', 'User') || die $sth->errstr;
ACHTUNG:
HIER IST WIEDER EIN FINISH obwohl danach noch ein $sth kommt!!
$sth->finish;
## HIER VERWENDE ICH $second_$sth für $sth damit es zu keinen
Problemen kommt (hoffe ich)
$second_sth = $dbh->prepare("INSERT INTO foobar VALUES (?, ?, ?, ?)") || die $dbh->errstr;
$second_sth->execute('', 'a', 'b', 'c') || die $sth->errstr;
$second_sth->finish;
$dbh->disconnect;
=====================================================================================
Script No. 4
#!/usr/bin/perl
use DBI;
use strict;
use CGI;
my $cgi = CGI->new();
print "Content-type: text/plain\n\n";
my $dbh = DBI->connect('DBI:mysql:database=foobar;host=localhost', '', '') || die $dbh->errstr;
my $sth = $dbh->prepare("INSERT INTO customers VALUES (?, ?)") || die $dbh->errstr;
$sth->execute('', 'User') || die $sth->errstr;
## ACHTUNG HIER IST KEIN FINISH !
## Hier ist wieder $second_sth und so...
$second_sth = $dbh->prepare("INSERT INTO foobar VALUES (?, ?, ?, ?)") || die $dbh->errstr;
$second_sth->execute('', 'a', 'b', 'c') || die $sth->errstr;
$second_sth->finish;
$dbh->disconnect;
=====================================================================================
ANMERKUNG
Mir ist unklar wie das gehen soll.
Das sind _TEST-Scripte_ !
Also normalerweise würde ich wegen 2 INSERT's sowas
nicht machen aber das icst nur zum lernen!
Danke,
Aqua