17 messages in com.mysql.lists.mysqlRe: HELP!!
FromSent OnAttachments
Mike Podlesny18 Dec 2000 11:39 
Eric Fitzgerald18 Dec 2000 11:40 
Eric Fitzgerald18 Dec 2000 11:45 
Mike Podlesny18 Dec 2000 11:49 
Mike Podlesny18 Dec 2000 11:49 
Sam Masiello18 Dec 2000 11:55 
Jason Terry18 Dec 2000 11:56 
Juan Jose Natera Abreu18 Dec 2000 11:57 
Mike Podlesny18 Dec 2000 12:05 
Eric Fitzgerald18 Dec 2000 12:05 
John Cichy18 Dec 2000 13:04 
John Cichy18 Dec 2000 13:09 
Kip Turk18 Dec 2000 13:11 
Jack Dempsey19 Dec 2000 12:00 
Mike Podlesny20 Dec 2000 06:08 
Greg Cope20 Dec 2000 06:19 
Mike Podlesny20 Dec 2000 06:21 
Subject:Re: HELP!!
From:Eric Fitzgerald (er@amntv.com)
Date:12/18/2000 11:40:41 AM
List:com.mysql.lists.mysql

I have to go through this line by line, as you didn't give error message :)

----- Original Message ----- From: "Mike Podlesny" <m.po@labcat.com> To: "mySQL Mailing List" <mys@lists.mysql.com> Sent: Monday, December 18, 2000 11:39 AM Subject: HELP!!

I wrote the following code in PERL to retrieve some information from a

mySQL database. Somewhere it generates an error and I am clueless at this point.

#!/usr/local/bin/perl

Check your she-bang, just rewrite it for safety

use DBI;

# Initialize variables and objects. my $db = "iwant_db"; my $user = "username;

Where's your end "?

my $password = "mypassword"; my $hostname = "host.mysql.com"; my $data_source = "DBI:mysql:$db:$hostname";

There's a prob, should read : my $data_source = "DBI:mysql:$db;host=$hostname" notice the semicolon and host= part

# Connect to the database. my $dbh = DBI->connect($data_source, $user, $password) or die "Failed to connect to host\n";

$sth = $dbh->prepare("SELECT * FROM Categories");

Not sure if this matters, but are you positive your table name has a capital C?

$sth->execute();

# Read the matching records and print them out while (@data = $sth->fetchrow_array()) { my $Category_Name = $data[1];

You want to pull the **SECOND** column returned?

print "\t$Category_Name\n"; }

if ($sth->rows == 0) { print "There are no categories.\n\n"; }

$sth->finish; $dbh->disconnect;