Leser: 1
|< 1 2 >| | 11 Einträge, 2 Seiten |
QuoteCan't locate object method "fetchall_arrayref" via package "sth" (perhaps you forgot to load "sth"?) at f:\perl\scripte\feurio_cddb\sql_abfrage.cgi line 215.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#/usr/bin/perl -w
use strict;
use CGI qw(:standard);
use DBI;
use CGI::Carp qw(fatalsToBrowser);
######### [...]
sub verbindung_zur_datenbank {
# baut Verdindung zur Datenbank auf
my $datasource = "DBI:mysql:database=feurio_cddb;host=localhost";
my $db_user = "sql";
my $db_pass = "sql";
(my $dbh_cd = DBI->connect($datasource, $db_user, $db_pass, {'RaiseError' => 1}) )
|| print "\nFehler beim connect zur Datenbank\n";
return $dbh_cd;
}
######### [...]
my $dbh = verbindung_zur_datenbank(); # $dbh: database handle
my $sth = $dbh->prepare($sql); # $sth: statement handle
$sth->execute();
my $result = sth->fetchall_arrayref(); #>> hier ist Zeile 215
for (my $i=0; $i = @{$result}-1; $i++) { # Zeilen durchlaufen
print "$result->[$i][2]<br>";
}
$sth->finish();
$dbh->disconnect();
return \$dbh_cd;
my $sth = $$dbh_cd->prepare($sql) or die DBI::errstr;
my $result = sth->fetchall_arrayref();
1
2
3
4
5
6
7
while (my $set = $sth->fetchrow_hashref()) {
# mach was mit hashref $set, z.B.
foreach (keys %$set) {
print "$_ => $set->{$_}<br>\n";
}
print "<hr>\n";
} # while
Quotemy $result = sth->fetchall_arrayref(); #>> hier ist Zeile 215
for (my $i=0; $i = @{$result}-1; $i++) { # Zeilen durchlaufen
print "$result->[$i][2]<br>";
}
QuoteDBD::mysql::st fetchrow_hashref failed: fetch() without execute() at f:\perl\scripte\feurio_cddb\sql_abfrage.cgi line 224.
Quote[/quote]DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at f:\perl\scripte\feurio_cddb\sql_abfrage.cgi line 224.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$sql = "select * from lieder;";
# ORDER BY l.interpret, l.titel;
my $dbh = verbindung_zur_datenbank(); # $dbh: database handle
my $sth = $dbh->prepare($sql); # $sth: statement handle
$sth->execute()
|| die "Content-type: text/html\n\n"
."## Fehler bei execute() ##";
print "## nach execute() ##<br>";
# my $result = $sth->fetchall_arrayref(); # alle Zeilen / Spalten im verketteten Hash
#
# for (my $i=0; $i = @{$result}-1; $i++) { # Zeilen durchlaufen
# print "$result->[$i][2]<br>";
#
#
# }
while (my $set = $sth->fetchrow_hashref()) {
# mach was mit hashref $set, z.B.
foreach (keys %$set) {
print "$_ => " . $set->{$_} . "<br>\n";
} $sth->finish();
print "<hr>\n"; $dbh->disconnect();
} # while
1
2
3
4
5
6
7
8
9
10
11
$sql = "select * from lieder;";
my $dbh = verbindung_zur_datenbank();
my $sth = $dbh->prepare($sql);
$sth->execute() or die "Content-type: text/html\n\n"
while(my @row = $sth->fetchrow_array) {
print @row[2] . '<br>';
}
$sth->finish();
$dbh->disconnect();
|< 1 2 >| | 11 Einträge, 2 Seiten |