...

View Full Version : querying a mysql table



bazz
07-20-2006, 03:30 PM
Hi,

Still a newbie to mySQL.

I want to query a specific table in the Db and output all the filed names to my perl script. This is for building a web form on the fly for adding new subscribers.

I am confused between building an array of the fields info and, querying using a $query variable.

here is the query code so far.



my $db = 'this';
my $server = 'that';
my $port = '1234';
my $user = 'theOther';
my $pass = 'another';
my $fieldsInAccountsTable;

my $dbh = DBI->connect("DBI:mysql:$db:$server:$port", $user, $pass,
{RaiseError => 1, PrintError => 0, AutoCommit => 1})
or die "Can't connect: DBI->errstr()";

my $fieldsInAccountTable = I'm stuck here

# disconnect from the MySQL server
$dbh->disconnect();




Bazz

Kid Charming
07-20-2006, 04:01 PM
You can get a list of columns with a SHOW COLUMNS (http://dev.mysql.com/doc/refman/5.1/en/show-columns.html) query.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum