in reply to MySQL and Perl... Update record Prob

It looks to me that you cut & pasted a bit to place the code in this node, but just to double check... You should only call ->disconnect() once. In DBI, you do...

$dbh = DBI->connect(); $dbh->do(); $sth = $dbh->prepare(); $sth->execute(); # And other methods for dealing with your data $dbh->commit() or $dbh->rollback(); $dbh->disconnect();

In the code snippets you provided, you have a ->disconnect() after every ->do(). The other thing is that you seem to be using undef to mean a NULL. I am not sure if you can do that with placeholders. Just for kicks, try using '' (empty string) instead of undef and let us know.

Update: I just noticed that I gave out bad advice. The undef does not stand for a NULL but for an empty \%attr. Sorry for that.

Best regards

-lem, but some call me fokat

Replies are listed 'Best First'.
Re: Re: MySQL and Perl... Update record Prob
by powerhouse (Friar) on Feb 03, 2003 at 06:26 UTC
    Ok, I replaced "undef" with "''"

    It now looks like this... I'll show a little more code:
    if (defined($in{new_aff}) && $in{new_aff} == 1) { # Checks to see if # they are adding our Affiliate Program to their registration if ($in{tax_id} ne "") { # Checks to see if they # added a tax id number for when we pay them $dbh->do (qq{ UPDATE reg_users SET tax_id = ? WHERE username = + ? }, '', $in{tax_id}, $username); } # Ok, these were required fields IF they checked the box which + made this # execute from above $dbh->do (qq{ UPDATE reg_users SET aff_url = ? WHERE username = ? +}, '', $in{aff_url}, $username); # the one above added their Website for us to view $dbh->do (qq{ UPDATE reg_users SET aff = ?, aff_su_date = ? WHERE +username = ? }, '', "yes", $formated_date, $username); # This one adds the affiliate program to the reg_users table. +it basically just # turns it 'on' } $dbh->do (qq{ UPDATE reg_users SET html_email = ? WHERE username = + ? }, '', $in{html_email}, $username); # this one just above was in a different part of the form, I j +ust added it. # It asks them if they support HTML email for our eMail update +s, they can # turn it off and on in the "registered users" manager I built +. $dbh->disconnect(); # Ok, now this finally disconnects.

    It still does not work. It does not update these columns: html_email, tax_id and aff_url

    The rest are updated (aff and aff_su_date)

    Since those two get updated and the rest do not, I'm very lost. Like I said the $in{var} variables that are being called do have values. I don't know why MySQL is not updating them in the SQL syntax Perl is giving it.

    Still lost.

    Any other ideas?

    Thx,
    Richard.

      Take a look at the ->trace() method. It allows your script to generate copious amounts of debug information related to DBI. Also, try moving this script to a standalone (as opposed to a CGI) so that you can easily check and troubleshoot.

      Also please be aware that I made a mistake in my earlier post. You were indeed correct when using undef in the ->do() statements. Probably it was the time...

      Best regards

      -lem, but some call me fokat