since i've recently been doing lot's of db stuff lately (for me anyway) and you seem to have little db/SQL experience at all... i'd say skip to the next level up and use Class::DBI which sits atop Ima::DBI and DBI and does alot of work for you.

assuming...

#!/usr/bin/perl use strict; use warnings; # a database - 'phpbbdb' # a database user - 'dbuser' # a database password - 'dbpass' # a table - 'passwords' # # mysql> describe passwords; # +--------+--------------+------+-----+---------+-------+ # | Field | Type | Null | Key | Default | Extra # | # +--------+--------------+------+-----+---------+-------+ # | user | varchar(16) | | PRI | | # | # | passwd | varchar(128) | YES | | NULL | # | # +--------+--------------+------+-----+---------+-------+ # # mysql> select * from passwords; # +-------+------------+ # | user | passwd | # +-------+------------+ # | walla | washington | # +-------+------------+ package MyDB; use base 'Class::DBI'; MyDB->set_db( 'Main', 'dbi:mysql:database=phpbbdb', 'dbuser', 'dbpass' ); package MyPasswords; use base 'MyDB'; MyPasswords->table( 'passwords' ); MyPasswords->columns( All => qw/ user passwd / ); package main; die << "_USAGE_" unless @ARGV; Usage: $0 <username> [<username> ...] Display the password(s) for username(s)! _USAGE_ foreach my $user (@ARGV) { my $info = MyPasswords->retrieve( $user ); printf "user: %s password: %s$/", $info->user(), $info->passwd(); } exit;

and a little test

$ test.pl walla
user: walla password: washington
$

Update/Addendum: the users will really hate it if they end up having to login twice. phpBB may be using cookies for session management, and may store some of that info in the database as well. it would be ideal if your script could arrange to have the cookie passed to it as well and use the cookie contents and a database query to allow access instead of asking for username/password again.


In reply to Re: Extracting data from mySQL by zengargoyle
in thread Extracting data from mySQL by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.