Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: postgresql dbi connection problem

by ralphie (Friar)
on Dec 20, 2001 at 01:35 UTC ( [id://133270]=note: print w/replies, xml ) Need Help??


in reply to postgresql dbi connection problem

thanks to you both for your comments ... i've only been able to address this a little since my original post. krazken seems close to the mark, although single-quoting the value held in the scalar results in the same lack of recognition, other quoting schemes do result in strings getting passed to the statement, although the strings themselves don't quite correspond to the username and as a result authentication fails. i'll be playing with this more.

for zapawork, here's the beginning of of the script from which the problem arises...

#!/usr/bin/perl -w sub BEGIN { $ENV{DISPLAY}= "machine:0.0"; } use Carp () ; use CGI qw( ::standard );; use CGI::Carp qw( fatalsToBrowser ); use DBI; use DBD::Pg; our $counter = 0; our $full=new CGI; print $full->header; our $dbh; $path_info = $full->path_info; my ($param1,$param2); $param1='username'; $param2='password'; my $username; $username=$full->param($param1); my $password; $password=$full->param($param2); my $database='jrado'; my $driver='Pg'; my $host='raider-ralph'; my $dsn="DBI:$driver:dbname=$database;host=$host"; $username=~s/^\s+//; $password=~s/^\s+//; unlink '/home/www/dbitrace.log6a' if -e '/home/www/dbitrace.log6a'; DBI->trace(2,'/home/www/dbitrace.log6a'); $dbh=DBI->connect($dsn,$username,$password) or die print "error connec +ting to database ", $DBI::errstr, "\n";

the initial portion of the working script is as follows:

#! /usr/bin/perl -Tw ##use strict; use CGI qw(:all); ##list.cgi ##set up the postgresql interface use DBI; use DBD::Pg; my $match; my $begdate; my $enddate; our $username; our $password; $match=''; $begdate=''; $enddate=''; our $list=new CGI; $begdate=$list->param('begdate'); $enddate=$list->param('enddate'); $match=$list->param('match'); $username=$list->param('username'); $password=$list->param('password'); ##declare scalars ##dsn-related my $host; my $db; my $driver; my $dsn; my $database; our $key; $database='jrado'; $driver='Pg'; $user=''; $host='raider-ralph'; $dsn="DBI:$driver:dbname=$database;host=$host"; ##database handle my $dbh_list; unlink '/home/www/dbitrace.log4' if -e '/home/www/dbitrace.log4'; DBI->trace(2,'/home/www/dbitrace.log4'); $username=~s/^\s+//; $password=~s/^\s+//; $dbh_list=DBI->connect($dsn,$username,$password) or die print "ACCESS +DENIED";

as you can see, there's nothing fancy in either one. in about an hour, i'll be out of here for the next week and a half and i'll probably only intermittently be able to cloister, but i appreciate any input you have.

ralphie

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://133270]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-18 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found