#!/usr/bin/perl -w
use CGI;
use strict;
use DBI;
my $hello ="hello";
my $query = new CGI->new();
print $query->header("text/html"),
$query->start_html(-title => "Database Test"),
$query->p("Database Test"),
my $db_handle = DBI->connect("dbi:mysql:database=Test;host=localhost;user=root;")
or die;
my $sql = "SELECT * FROM users WHERE id = 2";
my $statement = $db_handle->prepare($sql)
or die;
$statement->execute()
or die;
while (my $row_ref = $statement->fetchrow_hashref())
{
my $holder = $row_ref->{email};
print $holder;
}
$db_handle->disconnect();
$query->end_html;
Basically I get the correct output which is an email address. But i also get an unwanted hashcode..
DBI::db=HASH(0x8382f78)blabla@bla.co.uk
I get no compile errors or anything so im wondering why DBI is getting printed out...
Maybe it has something to do with the fetch_row method?
Any help is much appreciated.
use CGI;
use strict;
use DBI;
my $hello ="hello";
my $query = new CGI->new();
print $query->header("text/html"),
$query->start_html(-title => "Database Test"),
$query->p("Database Test"),
my $db_handle = DBI->connect("dbi:mysql:database=Test;host=localhost;user=root;")
or die;
my $sql = "SELECT * FROM users WHERE id = 2";
my $statement = $db_handle->prepare($sql)
or die;
$statement->execute()
or die;
while (my $row_ref = $statement->fetchrow_hashref())
{
my $holder = $row_ref->{email};
print $holder;
}
$db_handle->disconnect();
$query->end_html;
Basically I get the correct output which is an email address. But i also get an unwanted hashcode..
DBI::db=HASH(0x8382f78)blabla@bla.co.uk
I get no compile errors or anything so im wondering why DBI is getting printed out...
Maybe it has something to do with the fetch_row method?
Any help is much appreciated.