Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hello all,
I am carrying on with my exploration of DBI and specifically DBD::Anydata and have a working script, but one of the sub routines comes up with the following error:

START of get_user_data<P> SELECT * FROM users WHERE id = ? [z] Use of uninitialized value at (ev +al 8) line 16. Use of uninitialized value at (eval 8) line 16. Use of + uninitialized value at (eval 8) line 16. Use of uninitialized value +at (eval 8) line 16. Use of uninitialized value at (eval 8) line 16. +Use of uninitialized value at (eval 8) line 16. Use of uninitialized +value at (eval 8) line 16. <P> result = z b b b b z NO Mon Jan 5 20:45:40 2004 Mon Jan 5 20:45:40 200 +4 0 50 1 0 0 0 Novice<P> User Data = z b b b b z NO Mon Jan 5 20:45:40 2004 Mon Jan 5 20:45:40 +2004 0 50 1 0 0 0 Novice<P> Judoka Limit = 1

The subroutine and script works fine (so far), but the error keeps showing up, which A) worries me and B) looks terrible on a user interface.

Any help would be appreciated. The sub routine is listed below

Cheers,
LANCE


sub get_user_data { # This subroutine collects the users data from t +he user database print p("START of get_user_data") if $DEBUG; my @internal_user_data = @_; # This line takes t +he user_data passed to us from the previous routine (@_) and allocate +s it to our internal user data array my $entered_id = $internal_user_data[0]; # just + so that it is clearer later we create a variable from the passed dat +a # Use DBI to connect to the users.csv datafile #---------------------------------------------- +- my $dbh = DBI->connect('dbi:AnyData(RaiseError= +>1):'); # tell DBI we want to use the Anydata module in ./MyLibs $dbh->func( 'users', 'CSV', 'data/users.csv', ' +ad_catalog'); # Connect to the users.csv data file # select from the datafile the id for the user +ID from the array paased from the previous sub routine my @params = ($entered_id); + # Theese are the parameteres we will use in the SQL command abo +ve my $sql = "SELECT * FROM users WHERE id = ?"; + # this is the SQL command we want to execute print "$sql\n[@params]\n" if $DEBUG; + # if we are in debug mode print the SQL statement my $sth = $dbh->prepare( $sql ); + # prepare the SQL command $sth->execute( @params ); + # excecute the SQL using our parameters my @result = $sth->fetchrow_array; # this line +takes the results of the select and puts it in the array called RESUL +TS $dbh->disconnect(); # we are done with the datb +ase for now, so disconnect from it (MAY NOT BE NECESSARY) print p("result = @result")if $DEBUG; + # Prints the result of our SQL command if we are in debug mode. return (@result); print p("END of get_user_data") if $DEBUG; }

Kia Kaha, Kia Toa, Kia Manawanui!
Be Strong, Be Brave, Be perservering!

janitored by ybiC: Retitle from less-than-descriptive "Why do I get this error?" for search-friendlyness, balanced <code> tags around error message for legibility


In reply to DBD::Anydata, Use of uninitialized value at... by lwicks

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 perusing the Monastery: (8)
    As of 2014-08-27 22:22 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (253 votes), past polls