Hi guys/gals,
I've come across a bit of a roadblock in one of my recent projects
Basically, in Gcommunity.. I am loading an IFRAME of the below script;
use strict;
use lib '/var/www/html/sites/www.site.com/admin';
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use DBI;
my $DEBUG = 1;
my $IN = new CGI;
my $s = $IN->param('s');
my $dbh = DBI->connect( "dbi:mysql:dbname;host=localhost",
"user",
"pass",
{
RaiseError => 1,
AutoCommit => 0
}
) || die "Database connection not made: $DBI::errstr";
my $sql = qq{ SELECT * FROM comm_sessions WHERE sess_id = '$s' };
print STDERR qq{$sql has been run...\n} if $DEBUG > 0;
my $sth = $dbh->prepare( $sql );
$sth->execute();
my $check_sess = $sth->fetchrow_hashref || undef;
print STDERR qq|Command run, grabbed session ID $check_sess->{sess_user_fk}...\n| if $DEBUG > 0;
$dbh->disconnect();
my $cookie;
if ($check_sess->{sess_user_fk}) {
print STDERR qq|Found session: $check_sess->{sess_user_fk}..., writing cookie... \n| if $DEBUG > 0;
$cookie = $IN->cookie( -name => "remotelog", -value => "$check_sess->{sess_user_fk}", -path => '/' );
}
print $IN->header( -cookie => $cookie );
print "a";
Now, the debugging gives the correct info (in the error log, as its going to STDERR);
[Tue Feb 01 10:35:43 2005] [error] [client 81.153.50.125] Command run, grabbed session ID 1...,
[Tue Feb 01 10:35:43 2005] [error] [client 81.153.50.125] [Tue Feb 1 10:35:43 2005] session.cgi: DBI::db=HASH(0x828c2e0)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at /home/andy/web/sites/www.site.com/session.cgi line 32.
[Tue Feb 01 10:35:43 2005] [error] [client 81.153.50.125] Found session: 1..., writing cookie... ,
.. yet the cookie doesn't seem to be generated (I'm looking in the "Environment" part of "Setup").
Can anyone see the stupid mistake? I've been staring at this code for a few hours now... and its really hurting my head
TIA
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
I've come across a bit of a roadblock in one of my recent projects
Basically, in Gcommunity.. I am loading an IFRAME of the below script;
Code:
#!/usr/local/bin/perl use strict;
use lib '/var/www/html/sites/www.site.com/admin';
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use DBI;
my $DEBUG = 1;
my $IN = new CGI;
my $s = $IN->param('s');
my $dbh = DBI->connect( "dbi:mysql:dbname;host=localhost",
"user",
"pass",
{
RaiseError => 1,
AutoCommit => 0
}
) || die "Database connection not made: $DBI::errstr";
my $sql = qq{ SELECT * FROM comm_sessions WHERE sess_id = '$s' };
print STDERR qq{$sql has been run...\n} if $DEBUG > 0;
my $sth = $dbh->prepare( $sql );
$sth->execute();
my $check_sess = $sth->fetchrow_hashref || undef;
print STDERR qq|Command run, grabbed session ID $check_sess->{sess_user_fk}...\n| if $DEBUG > 0;
$dbh->disconnect();
my $cookie;
if ($check_sess->{sess_user_fk}) {
print STDERR qq|Found session: $check_sess->{sess_user_fk}..., writing cookie... \n| if $DEBUG > 0;
$cookie = $IN->cookie( -name => "remotelog", -value => "$check_sess->{sess_user_fk}", -path => '/' );
}
print $IN->header( -cookie => $cookie );
print "a";
Now, the debugging gives the correct info (in the error log, as its going to STDERR);
Quote:
[Tue Feb 01 10:35:43 2005] [error] [client 81.153.50.125] SELECT * FROM comm_sessions WHERE sess_id = 'fe2483116ded732fb37a4e5ee986e5b7' has been run..., [Tue Feb 01 10:35:43 2005] [error] [client 81.153.50.125] Command run, grabbed session ID 1...,
[Tue Feb 01 10:35:43 2005] [error] [client 81.153.50.125] [Tue Feb 1 10:35:43 2005] session.cgi: DBI::db=HASH(0x828c2e0)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at /home/andy/web/sites/www.site.com/session.cgi line 32.
[Tue Feb 01 10:35:43 2005] [error] [client 81.153.50.125] Found session: 1..., writing cookie... ,
.. yet the cookie doesn't seem to be generated (I'm looking in the "Environment" part of "Setup").
Can anyone see the stupid mistake? I've been staring at this code for a few hours now... and its really hurting my head
TIA
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

