Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-29 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found