hi all,

i have what seems to me to be an interesting problem ... i'm converting a series of html docs and cgi scripts that i use as a query engine to a couple of cgi scripts, one which receives authentication information while the other handles query processing. the query page is frame-based, and follows the example included in the cgi.pm readme.

the problem i'm having is that the connect string in the converted script won't work using variables for username and password. here's the output from the dbitrace log from the connect attempt...

DBI 1.20-nothread dispatch trace level set to 2 -> DBI->connect(DBI:Pg:dbname=jrado;host=raider-ralph, , ****) -> DBI->install_driver(Pg) for linux perl=5.006001 pid=3030 ruid=1 +001 euid=1001 install_driver: DBD::Pg version 1.01 loaded from /usr/local/lib +/perl/5.6.1/DBD/Pg.pm <- install_driver= DBI::dr=HASH(0x82459e4) -> default_user in DBD::_::dr for DBD::Pg::dr (DBI::dr=HASH(0x8245 +9e4)~0x82ec3d8 undef undef HASH(0x8109d38)) <- default_user= ( undef undef ) [2 items] at DBI.pm line 423 -> connect for DBD::Pg::dr (DBI::dr=HASH(0x82459e4)~0x82ec3d8 'dbn +ame=jrado;host=raider-ralph' undef **** HASH(0x8109d38)) pg_db_login pg_db_login: conn_str = >dbname=jrado host=raider-ralph<br> No Postgres username specified in startup packet. error 1 recorded: No + Postgres username specified in startup packet. !! ERROR: 1 'No Postgres username specified in startup packet.'

the log from a successful connection attempt, which i get when i explicitly pass a valid set of credentials in the connect string, is identical to that which i receive in the relevant portion of the earlier version when i pass the credentials in scalars. that log looks like this:

DBI 1.20-nothread dispatch trace level set to 2 -> DBI->connect(DBI:Pg:dbname=jrado;host=raider-ralph, (username d +eleted for post), ****) -> DBI->install_driver(Pg) for linux perl=5.006001 pid=32422 ruid= +1001 euid=1001 install_driver: DBD::Pg version 1.01 loaded fro +m /usr/local/lib/perl/5.6.1/DBD/Pg.pm <- install_driver= DBI::dr=HASH(0x8225fd8) -> connect for DBD::Pg::dr (DBI::dr=HASH(0x8225fd8)~0x8100750 'dbn +ame=jrado;host=raider-ralph' '(username deleted for post)' **** HASH( +0x80f6174)) pg_db_login pg_db_login: conn_str = >dbname=jrado host=raider-ralph user=(username + deleted) password=(password deleted) <- connect= DBI::db=HASH(0x8100714) at DBI.pm line 426

in both scripts the $username and $password scalars are successfully filled from parameters, and the connect statement is the standard $dbh=DBI->connect($dsn,$username,$password) or die print "error connecting to database ", $DBI::errstr, "\n";

obviously, the scalar values are not getting passed in the connect string in the problematic context, but at this point i'll be darned if i can figure out why. (those who feel i'm being excessively politically-correct by not using the more appropriate word above should recognize that i'm at a state computer, and lawyerz are everywhere.)

has anyone run into this before? i don't have enough hair left to keep pulling it out like this ...


In reply to postgresql dbi connection problem by ralphie

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.