Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^14: DBI Problem

by huck (Prior)
on Oct 01, 2017 at 01:39 UTC ( [id://1200437]=note: print w/replies, xml ) Need Help??


in reply to Re^13: DBI Problem
in thread DBI Problem

So is the destroy undefined the problem to chase?

No

you havent been paying attention at all have you? Somehow you still think this has to do with ExecuteQuery but it does not.

You want to make sure the session data is flushed before the database(handle) gets closed.

according to http://search.cpan.org/~markstos/CGI-Session-4.48/lib/CGI/Session.pm#A_Warning_about_Auto-flushing the best way is to use $session->flush(); since Explicit flushing after key session updates is recommended.

Another way would be to use my to lexically localize $session only to the blocks it is being actively used rather than having a lexical-global scope. but that relies on autoflushing by the destructor

Replies are listed 'Best First'.
Re^15: DBI Problem
by tultalk (Monk) on Oct 01, 2017 at 17:19 UTC

    Fixed. Thanks all.

    sub UpdateUserData { # $dbh->trace(2); my ($sid, $password,$email,$secret) = @_; $session = new CGI::Session("driver:MySQL",$sid, {Handle=>$dbh}); my $SQL = qq|SELECT id FROM $sql_session_table WHERE id = '$sid' | +; my $sth = ExecuteQuery($SQL); my ($tsid, $userid) = $sth->fetchrow_array(); if (!$tsid) { return 0; } else { my $userid = $session->param("user_id"); my $username = $session->param("username"); if (! defined $userid ){ return 0; } my $updateinfoemail = "webpass\@jala-mi.org"; my $passpart = ""; my $mailpart = ""; my $secretpart = ""; if ($password ne "") { $passpart = "password = '$password'"; } if (($email ne "") && ($password eq "")) { $mailpart = "email = '$email'"; } elsif (($email ne "") && ($password ne "")) { $mailpart = ", email = '$email'"; } if (($secret ne "") && ($password eq "") && ($email eq "")) { $secretpart = "secret = '$secret'"; } elsif (($secret ne "") && (($password ne "") || ($email ne "") +)) { $secretpart = ", secret = '$secret'"; } my $wherepart = " where user_id = '$userid'"; my $statement = "update $sql_user_table set $passpart $mailpar +t $secretpart $wherepart"; $SQL = qq| $statement |; my $sth1 = ExecuteQuery($SQL); # success so disconnect and send an e-mail with the missing/al +tered information to the user. $session->flush() or die "Unable to update session storage\n" +; my $password1 = "'06#$password&422'"; my $userid1 = "61345$userid"; my $message = "The member has updated their information throug +h the website. The member userid is :'$userid1'. Their new password i +s '$password1' "; my $subject = 'JALA Update Information Request.'; my $from = 'webmaster@jala-mi.net'; my $to = $updateinfoemail; my $body = $message; my $heading = "Member Update Information"; my $closing = "Office Manager: Please update the member databa +se."; my $signiture = "JALA Support"; my $result = SendMemberMail($subject,$from,$to,$heading,$body, +$closing,$signiture); return 1; } }
Re^15: DBI Problem
by tultalk (Monk) on Oct 01, 2017 at 02:28 UTC

    Somehow you still think this has to do with ExecuteQuery but it does not.

    No I don't. I was just looking at the dbh dbi around the calls to execute.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found