Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I attempted to reduce your code to something that just set information on a static entry, then printed all the entries. From this, I was able to see that the update worked just fine. So, I'd be inclined to think that the problem might be in the complicated stuff near the end of your code, and not in the actual database update code.

-Scott

#!/usr/bin/perl -w use strict; use DBI; #use autodie; $\="\n"; my $res_tbl="SOMETABLE"; my $loc_tbl="OTHERTABLE"; my $res_select_stmt = "Select * from $res_tbl order by id"; my $loc_select_stmt = "Select location from $loc_tbl where resource_id + = ?"; my $db="SOMEDB"; my $dbun="SOMEUN"; my $dbpw = 'SOMEPW'; my $dbhost="SOMEHOST.hostedresource.com"; my $res_tbl="resource_list"; my $loc_tbl="matrix_locations"; my $drh = DBI->install_driver("mysql") || print "install_driver failed +: $DBI::errstr <br/> +"; my $dsn = "DBI:mysql:database=$db;host=$dbhost"; my $dbh = DBI->connect($dsn,$dbun,$dbpw) || print "DB connect failed: +$DBI::errstr <br/>" my $res_select_stmt = "Select * from $res_tbl order by id"; my $loc_select_stmt = "Select location from $loc_tbl where resource_id + = ?"; my $update_res_stmt = "UPDATE $res_tbl SET name=?, link=?, availabilit +y=? WHERE id=?"; print "Updating $res_tbl item with stuff \n"; my $sth = $dbh->prepare($update_res_stmt) or warn "prepare UPDATE stat +ement failed: $dbh->errstr"; my $rv = $sth->execute("test","link test", "test availability", 7) || +warn "Execute update failed: $dbh->errstr"; $sth->finish; print "$res_tbl updated with return value '$rv'.\n"; my $select_sth = $dbh->prepare($res_select_stmt) || print "prepare sta +tement failed: $DBI::errstr <br/>"; $select_sth->execute() || print "execute statement failed: $DBI::errst +r <br/>"; my $results = $select_sth->fetchall_arrayref(); $select_sth->finish(); foreach my $row (@$results){ print join ',' , @$row; print '\n'; } $dbh->disconnect();

In reply to Re: Mystified by why my UPDATE statement is not reflected in my database display by 5mi11er
in thread Mystified by why my UPDATE statement is not reflected in my database display by OfficeLinebacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (9)
    As of 2014-12-26 22:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (176 votes), past polls