Thread perl mysql (8 answers)
Opened by hummelchen at 2005-01-28 13:17

renee
 2005-01-28 15:40
#32909 #32909
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use DBI;
my($main,$password,$nick);

my $db_name = "DBI:mysql:users"; ## den Datenbankname ersetzen
my $db_user = "root"; ## Benutzername
my $db_pass = ""; ## Passwort
my @ergebnis;
my $test;

my $dbh = DBI->connect("$db_name","$db_user","$db_pass") || die "Database connection not made: $DBI::errstr";
my $sql_insert = qq{insert into mitglieder (password,nick) values (?,?)};
my $sql_select = qq~SELECT * FROM user WHERE password = ? AND nick = ?~;
my $sql_update = qq~UPDATE user SET password = ? WHERE nick = ?~;
my $sth = $dbh->prepare($sql_select) or die $dbh->errstr();
$sth->execute($password,$nick) or die $dbh->errstr();
if($sth->fetchrow_array()){
$sth = $dbh->prepare($sql_update) or die $dbh->errstr();
$sth->execute($password,$nick);
}
else{
$sth = $dbh->prepare($sql_insert) or die $dbh->errstr();
$sth->execute($password,$nick) or die $dbh->errstr();
}


edit: könntest Du uns auch sagen wobei Du bei den Schleifen ein Problem hast??\n\n

<!--EDIT|renee|1106919657-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread perl mysql