www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: script error, help!!!

  1. #1
    Join Date
    May 2003
    Posts
    11

    Unhappy script error, help!!!

    I am trying to display my records from an oracle database with the code section below:

    while(@row=$sth->fetchrow_array)
    {
    ($fac,$dept,$deg,$major,$credits)=@row;
    print "<tr>";
    print "<td>$fac</td>";
    print "<td>$dept</td>";
    print "<td>$deg</td>";
    print "<td>$major</td>";
    print "<td>$credits</td>"; #line 30
    print "</tr>\n";
    }

    but i always get an error that says 'Use of uninitialized value in concatenation (.) or string at status.cgi line 30.'

    what must i do to solve this and get the results printed out?? I've been trying for quite long and nothing works, please help!!!

  2. #2
    Join Date
    Nov 2002
    Location
    England
    Posts
    693

    Try this

    hmmmmmmmmmmm sorry my example was poor...didnt know what i was on about lol
    Last edited by Scriptage; 05-08-2003 at 10:19 AM.

  3. #3
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    print "<td>".$credits."</td>";
    This and what the original poster had do the exact same thing.

    Casy, the error you're getting is because the value for the variable $credits is undef. You'll need to have it default to an empty string instead of the undefined value.
    Code:
    $credits ||= '';

  4. #4
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    lol sorry

    <------------noob

    But...I'm confused.......How can undef make a concatenation error????????? If it's undef then it just prints nothing!!!

    Try

    #!/usr/bin/perl

    $value = undef;

    print "$value";

    output: " " <-----------nothing

    !!!????!!!????
    Last edited by Scriptage; 05-08-2003 at 10:25 AM.

  5. #5
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    Now try it with warnings enabled, which they always should be.

  6. #6
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    yeah,
    use of uninitialised value in string
    not in concactenation!!!!!!!!!!!!!
    It is a concactenation error, which means perl is finding a . somewhere..... probably in $credits dont you think

    lol

  7. #7
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    Your example doesn't mention concatentation because you havn't concatenated anything. Replace with this line and see.
    Code:
    print "foo $value";
    which means perl is finding a . somewhere..... probably in $credits dont you think
    Don't confuse variable interpolation with evaling. A period occuring in an interpolated string will not be interpreted as a concatenation operator.

  8. #8
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    im on about the original posters example read it!!!

  9. #9
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    im on about the original posters example read it!!!
    I have read it. And I've answered it. And I've answered you. I'm not sure what you don't understand anymore.

  10. #10
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    she said she got an error saying concactenation error, an undef variable does not produce a concatenation error!

  11. #11
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    an undef variable does not produce a concatenation error
    It does if warnings are enabled. So... (a very mild amount of deductive thinking required here) the original poster must have warnings enabled.

  12. #12
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    no..it says use of unitialised value!!!!!!!!!!!!!!!!!1 not concactenation!!!!!!!!!!!!!! FFS

  13. #13
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    not concactenation
    The original poster's, or your example. Because the error message posted by the OP does say concatenation.

  14. #14
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    The original poster says she gets a concatenation error.....you say it is because a variable is undef. However....if you try my example you will find that an undef variable produces the error "use of unitialised value" not "concactenation".
    Understand???

  15. #15
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    ....if you try my example you will find that an undef variable produces the error "use of unitialised value" not "concactenation".
    Understand???
    Yes, I do understand. I understood 8 posts ago where I already told you why.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles