problems to connect to a mysql-database
am 10.07.2006 19:40:37 von azcpb
dear members,
i have some problems to fetch the data from a mysql database generated
with phpmyadmin. i'm a beginner in programming in perl. i'm nit sure
whther i chose a well formed expression to refer to the database. here
is the code:
$dbh =
DBI->connect("DBI:mysql:c\programme\xampp\mysql\data\lexikon ;localhost","myusername","mypassword")
or die "Keine Verbindung möglich: " . $DBI::errstr;
$sql = "select * from v";
$dbh->prepare($sql)
or die "prepare nicht möglich: " . $dbh->errstr();
$sth->execute()
or die "execute nicht möglich: " . $sth->errstr();
while (@row = $sth->fetchrow_array) {
print "@row\n";
}
$sth->finish;
$dbh->disconnect;
after having processed this code i exspect the engine to print the
values stored in table "v". this code is part of a cgi-script which
shall be used to a database which contains a thesaurus and to check whether
Re: problems to connect to a mysql-database
am 11.07.2006 01:12:07 von jeff
CAMPBELL, BRIAN D (BRIAN) wrote:
> One problem I see is this:
>
> Your Windows path delimiters act as escape chars in Perl.
>
> A couple of solutions:
>
> Double up the backslashes, e.g. "...:c\\programme\\xamapp\\..."
>
> Use single quotes to disable interpolation of escape chars: '...:c\programme\xamapp\...'
>
And a third solution (works fine on windows too):
Use forward slashes with either single or double quotes:
"c:/programme/xampp/..." or 'c:/programme/xampp/...'
--
Jeff
>
>
>
> -----Original Message-----
> From: Dr. Claus-Peter Becke [mailto:azcpb@online.de]
> Sent: Monday, July 10, 2006 10:41 AM
> To: dbi-users@perl.org
> Subject: problems to connect to a mysql-database
>
>
> dear members,
>
> i have some problems to fetch the data from a mysql database generated
> with phpmyadmin. i'm a beginner in programming in perl. i'm nit sure
> whther i chose a well formed expression to refer to the database. here
> is the code:
>
> $dbh =
> DBI->connect("DBI:mysql:c\programme\xampp\mysql\data\lexikon ;localhost","myusername","mypassword")
> or die "Keine Verbindung möglich: " . $DBI::errstr;
> $sql = "select * from v";
> $dbh->prepare($sql)
> or die "prepare nicht möglich: " . $dbh->errstr();
> $sth->execute()
> or die "execute nicht möglich: " . $sth->errstr();
> while (@row = $sth->fetchrow_array) {
> print "@row\n";
> }
> $sth->finish;
> $dbh->disconnect;
>
> after having processed this code i exspect the engine to print the
> values stored in table "v". this code is part of a cgi-script which
> shall be used to a database which contains a thesaurus and to check whether
>
>