#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    2
    Rep Power
    0

    Angry


    Hi all...

    I am making a CGI that runs this...

    #!/usr/bin/perl

    use DBI;

    .
    .
    .

    while (my $hash_ref=$sth->fetchrow_hashref())
    {
    print"$hash_ref->{name} and $hash_ref->{age}n"
    }

    this worked perfectly on terminal window...

    >PERL MYCGI.CGI

    but when i tried trough HTTP, it only prints "and"...

    WHY?

    Thanks...

    landim2@brhs.com.br

  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    I'm not sure why it acts like that because I never reference my hashes like that, but I'd figure the '->' reference is being parsed by the browser as a tag error. Try:

    Code:
    print $hash->{name} . " and " . $hash->{age};
    or my favorite

    Code:
    print "$hash{name} and $hash->{age}";
    Also if your working on a remote web server make sure you're connecting to the right data base. I'm sure you've already figured this out but I thought I might give it a guess anyway.

    Later,
    t
  4. #3
  5. No Profile Picture
    PerlGuy
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Posts
    720
    Rep Power
    42

    Wink


    check your code for the CGI part. It may be that your variables are not being passed to the script properly or that you are not passing them back from the script to the browser properly. Also, I don't see a 'use CGI;' at the top of your script or any other code indicative of a CGI script. You may have to check that. Next time, you may want to include more code to get a more specific answer.

    Hope this helps.
    - dsb -
    Perl Guy

IMN logo majestic logo threadwatch logo seochat tools logo