develooper Front page | perl.beginners | Postings from October 2009

DBI driving me nuts ... !

Thread Next
From:
Gregory Machin
Date:
October 6, 2009 11:44
Subject:
DBI driving me nuts ... !
Message ID:
30200a940910061144q608d70b3q641ee16fdbc9b7b6@mail.gmail.com
Hi
Please can you advise ?

#!/usr/bin/perl

use Mysql;

$dbh = Mysql->connect("localhost","mailscanner","root","c0nc3pt") or
die ("Error " . Mysql->errno . " - " . Mysql->errstr);
$sql = "SELECT to_address FROM maillog LIMIT 10;";
$sth = $dbh->query($sql) or die ("Error " . Mysql->errno . " - " .
Mysql->errstr);
while (@row = $sth->fetchrow){
        print "$row /n";
}

which gives this

[root@mail10 ~]# perl addressrep2.pl
 /n /n /n /n /n /n /n /n /n /n[root@mail10 ~]#

when it should give the same output as

Database changed
mysql> SELECT to_address FROM maillog LIMIT 10
    -> ;
+----------------------------+
| to_address                 |
+----------------------------+
| ivork@systems.xxx        |
| tkekana@stpeters.xxx     |
| dfourie@howden.xxx       |
| melaniea@mdlulisharp.xxx |
| ericm@mdlulisharp.xxx    |
| desiree@oas.xxx          |
| dbalakisten@multivid.xxx |
| bharpin@webb.xxx         |
| jcventer@multivid.xxx    |
| adele@troika-iw.xxx        |
+----------------------------+
10 rows in set (0.00 sec)

mysql>



what am I doing wrong ?

Thanks

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About