Gossamer Forum
Home : General : Databases and SQL :

ERROR:'DBI::db=HASH(0x1b172a4)->select_arrayref()

Quote Reply
ERROR:'DBI::db=HASH(0x1b172a4)->select_arrayref()
Can any one tell me what is wrong with this? I have lokked a teh tec references and I cannot see what is wrong. Can I put it together like this? I want to lift the whole row Name and collectit to use in another perl script but I cannot get past this and would it actually let me do this? It is in MySql Apache and Perl

use DBI;
$DBH= DBI->connect("DBI:mysql:Guide")or die "\n

($DBI::err) : $DBI::errstr\n";
$sth= $DBH->prepare(qq{$DBH->select_arrayref()
select Name
from Family
while(@row =$sth->fetchrow_array)
{
print qw($row[0]\t$row[2]\n);
}
});
$sth->execute();
$sth->finish();
$DBH->disconnect();

I get this message:

Bla Bla

DBD ::mysql::st execute failed: you have an error in your SQL syntax near 'DBI::db=HASH(0x1b172a4)->select_arrayref()

select Name

from Family

whil' at line 1 a C:/ bla bla line 11

line 11 seems to be });


Any Ideas at all please thanks Chris
Quote Reply
Re: [Silver Machine] ERROR:'DBI::db=HASH(0x1b172a4)->select_arrayref() In reply to
your prepare() seems all messed up. see if this helps any:

Code:
use DBI;
my $DBH = DBI->connect("DBI:mysql:Guide") or die "$DBI::err : $DBI::errstr";
my $sth = $DBH->prepare(qq|select Name from Family|);
$sth->execute();
while (my $row = $sth->fetchrow_arrayref()) {
print qw($row->[0], "\n");
}
$sth->finish();
$DBH->disconnect();

you are only selecting one field, by the way, so $row[2] would have been empty (which is why I omitted it).

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] ERROR:'DBI::db=HASH(0x1b172a4)->select_arrayref() In reply to
Well it is nearer but all I can get back is blanks it sends the right number of them mind!

C:\Program Files\Apache Group\Apache2\cgi-bin>dol2.pl
$row->[0],"\n"$row->[0],"\n"$row->[0],"\n"$row->[0],"\n"$row->[0],"\n"$row->[0],
"\n"$row->[0],"\n"$row->[0],"\n"$row->[0],"\n"
C:\Program Files\Apache Group\Apache2\cgi-bin>

Any more suggestions please, I know it is probably very easy but no matter how I fiddled with it I have got nowhere! Chris