perl help

matthew9090

New Member
Messages
13
Reaction score
0
Points
0
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.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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 [FONT="Courier New"]exit[/FONT] 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;
}[/code]

[quote="matthew9090, post: 708498"]if i put the h2 tag at the getUsername() it comes up with an error.[/QUOTE]
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?
 
Top