Thread erstes Skript für die Datenbank-Verbindung (61 answers)
Opened by Michael47 at 2016-02-03 19:48

GwenDragon
 2016-02-03 20:08
#183708 #183708
User since
2005-01-17
14542 Artikel
Admin1
[Homepage]
user image
Wenn dein connect fehlschlägt stirbt das Programm, gibt aber keinen Header an den Server aus, das erzeugt den 500er.

Ersetze:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
# Datenbank-Verbindung aufbauen
my $dbh = DBI->connect(
'dbi:mysqlPP:database=pizzadb;host=127.0.0.1;port=3306',
'root', '') || die "Kann keine Verbindung zum MySQL-
Server aufbauen: $DBI::errstr\n";

# Datenbank-Verbindung beenden
$dbh->disconnect;

print "Content-type: text/html\n\n";

print "<html><body>Hallo Welt, ich bin MySQL-
fähig!</body></html>";

druch
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 # Datenbank-Verbindung aufbauen
my $dbh = DBI->connect(
'dbi:mysqlPP:database=pizzadb;host=127.0.0.1;port=3306',
'root', '');

my $not_connected = '';
if (! $dbh) {
$not_connected = 'NICHT'; # Zeichenkette falls fehlgeschlagen
}
else {
# Datenbank-Verbindung beenden
$dbh->disconnect;
}

print "Content-type: text/html\n\n";

print "<html><body>
<p>Hallo Welt, ich bin $not_connected MySQL-fähig!</p>
<p>DEBUG: $DBI::errstr</p>
</body></html>";

Last edited: 2016-02-03 20:11:38 +0100 (CET)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread erstes Skript für die Datenbank-Verbindung