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

How about some error handling? Why are we asking this person to turn on DBI's tracing before he adds any normal error handling? Do something like the following with your database requests to see if the database is returning any errors.

$dbh->do(qq{sql statement}) || die $dbh->errstr;
--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';

Replies are listed 'Best First'.
Re: Re: MySQL and Perl... Update record Prob
by powerhouse (Friar) on Feb 03, 2003 at 09:59 UTC
    Ok, Nothing has worked yet. I do have the RaiseError set to 1 in my module I created.

    My Databases all work, and update correctly with that module, this is the only problem I'm having.

    I'm getting even more confused now :o(

    Why would everything else work, but those two fields not?
    Is there a problem with MySQL using those two table names?(tax_id && aff_url)
    Here is the part of my code that is not working completely:
    if (defined($in{new_aff}) && $in{new_aff} == 1) { if ($in{tax_id} ne "") { $dbh->do (qq{ UPDATE reg_users SET tax_id = ? WHERE username = + ? }, undef, $in{tax_id}, $username) || error("Error on +MySQL Update: $DBI::errstr"); } $dbh->do (qq{ UPDATE reg_users SET aff_url = ? WHERE username = ? +}, undef, $in{aff_url}, $username) || error("Error on MyS +QL Update: $DBI::errstr"); $dbh->do (qq{ UPDATE reg_users SET aff = ?, aff_su_date = ? WHERE +username = ? }, undef, "yes", $formated_date, $username) || error("Err +or on MySQL Update: $DBI::errstr"); } $dbh->do (qq{ UPDATE reg_users SET html_email = ? WHERE username = + ? }, undef, $in{html_email}, $username) || error("Error on +MySQL Update: $DBI::errstr"); $dbh->disconnect();

    I added the || error for each of them. I never errors out.

    any other Ideas?

    Should I try that trace idea now?

    Thx,
    Richard.

      Where is $username coming from? Did you read it from a file and forget to chomp? Do other queries using this value in a where clause work?

      --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
        $username is coming from a required configuration file, it's a global field for when they are logged in. It's pulled from the database, and then put into a session, managed by Apache::Session::MySQL

        Yes, all the other WHERE clauses that use it work.

        Thx,
        Richard.
      Have you checked the value of $in{tax_id}?

      e.g.

      if ($in{tax_id} ne "") { warn "updating $username tax to $in{tax_id}"; $dbh->do (qq{ UPDATE reg_users SET tax_id = ? WHERE username = ? }, undef, $in{tax_id}, $username) || error("Error on +MySQL Update: $DBI::errstr"); } else { warn "Not updating tax_id for $username (\$in{new_aff} == $in{new_ +aff})"; }
      If you don't see a warning then the code isn't be executed for some reason. If you do see a warning, then you'll know exactly what's going on.

      rdfield

        Ok, I added the warn before each do statement, and I do see them in the error log.

        They all look right, but it is still not updating my database. Everything elses get's updated. I am wondering if they are just illegal names or something, to MySQL.

        Any other ideas?

        Richard.