View Full Version : querying a mysql table

07-20-2006, 04:30 PM

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


Kid Charming
07-20-2006, 05: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.