+ Reply to Thread
Results 1 to 2 of 2

Thread: perl help

  1. #1
    matthew9090 is offline x10Hosting Member matthew9090 is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    13

    perl help

    i want to display "welcome (yourname)" when you login. it works fine but i am starting to put html into the perl program but i use a function called getUsername() and i can put the h2 tag on the print welcome bit but the getusername i carn't and it comes up with an internal server error. so there's a big welcome and a small yourname.

    here is the script:

    sub RetrieveSession
    {
    my $sessman = SessMan->new();
    if ( ! $sessman->retrieveSession($sid))
    {
    print "Failed to retrieve existing session: ".$sessman->getError();
    exit();
    }
    print "<h2>Welcome</h2>".$sessman->getUsername();
    return(1);
    }
    if i put the h2 tag at the getUsername() it comes up with an error.

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: perl help

    Use [php], [html] or [code] tags (as appropriate) to format code.

    As we're not oracles, give us the exact error message ("internal server error" is a generic error from the Apache server and tells us nothing about what's wrong). To get the exact error, check the error log.

    If you're not already doing so, do your development on your own server so you have more control. It makes it much easier to debug and your users can continue to use the public site without interruption.

    You shouldn't use exit when outputting an HTML document, as it will be malformed. Instead, return a value indicating failure.

    Code:
    sub printWelcome {
      my $sid = shift;
      my $sessman = SessMan->new();
      if ( ! $sessman->retrieveSession($sid)) {
        print "Failed to retrieve existing session: ".$sessman->getError();
        return 0;
      }
      print "<h2>Welcome ", $sessman->getUsername(), '</h2>';
      return 1;
    }
    Quote Originally Posted by matthew9090 View Post
    if i put the h2 tag at the getUsername() it comes up with an error.
    How are you "putting the h2 tag at the getUsername()"? We can't answer questions about what's going wring without seeing the exact code. Is the sample code supposed to generate an error?
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Perl?
    By pzelnip in forum Programming Help
    Replies: 4
    Last Post: 05-29-2009, 12:10 AM
  2. Perl Help
    By cgrim29588 in forum Free Hosting
    Replies: 1
    Last Post: 02-16-2009, 02:06 PM
  3. Eblah Perl/Perl Mods
    By vol7ron in forum Free Hosting
    Replies: 3
    Last Post: 04-08-2008, 05:50 PM
  4. perl cgi
    By schmidte in forum Free Hosting
    Replies: 5
    Last Post: 10-15-2007, 06:27 PM
  5. To all those using Perl and CGI
    By DefecTalisman in forum Free Hosting
    Replies: 0
    Last Post: 09-16-2007, 03:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers