#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); use DBI; #Variabeln Deklarierung my $dbname="cdliste"; my $username="root"; my $pw="123"; my $db = "DBI:mysql:$dbname"; #Die Verbindung zur Datenbank wird hergestellt my $dbh = DBI->connect($db, $username, $pw, { RaiseError => 1 }) || die("Kann DB nicht öffnen!"); sub selecthashref ($){ my $sth = $dbh->prepare( $_[0] ) or return "$DBI::err: $DBI::errstr"; $sth->execute() or die $dbh->errstr(); return $sth; }; #Legt den Dokumenttypen fest print "Content-type: text/html; charset=iso-8859-1\n\n"; my $sth = selecthashref("SELECT * FROM ordner ORDER BY ordnername ASC"); while ($row_ref = $sth->fetchrow_hashref()){ print "$row_ref->{ordnerid}\n"; }