#!/usr/bin/perl useDBI; chomp($id = <STDIN>); $database=""; $user=""; $host="localhost"; $password=""; $dbh=DBI->connect('DBI: mysql: $database: $host, $user,$password') or die "Can't connect: ", DBI->errstr; $sth = $dbh->prepare("SELECT id, title, author from book where id = $id"); $sth->execute(); print "Contents of book table." while(@row = $sth->fetchrow_array()) { print "id:$row[0]\n"; print "title:$row[1]\n"; print "author:$row[2]\n"; } $sth->finish(); $dbh->disconnect;
i keep getting compile erros when i run this in a unix shell. i took out the values of the variables for the passwords to post this here...
i get a syntax error it says near ) { on the while look and at near the } on the while loop.
anyone know what is wrong wit hthis code?