Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    querying a mysql table

    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.

    Code:
    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

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can get a list of columns with a SHOW COLUMNS query.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •