Mailing List Archive

Unexpected error on page ....
Hi ,

I'm encountering this message on a particular page ... with a subroutine
&dbconnect which is in a lib.pl file and i have written something like this
..

[.- require "/apps/util/lib.pl"; &dbconnect; $sysdate=`date
'+%Y%m%d%H%M'`; $sth =$dbh->prepare("select * from news where newsid =
'$rel' and $sysdate >newsdate"); $sth -> execute; $head = $sth -> {NAME};
$dat = $sth -> fetchall_arrayref; -]

And this error message comes up very rarely but if i refresh the page then
i get the output ... The following is the error message

" The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, webmaster@polycom.com and inform
them of the time the error occurred, and anything you
might have done that may have caused the error.

[14290]ERR: 24: Line 28: Error in Perl code: Undefined subroutine
&HTML::Embperl::DOC::_7::dbconnect called at
/apps/pcom/newsEvents/pr_archive/pr_news.html line 28.

Apache/1.3.9 (Unix) ApacheJServ/1.0 mod_perl/1.21 mod_ssl/2.4.10
OpenSSL/0.9.4 HTML::Embperl 1.3b2 [Wed Apr 5
17:58:15 2000] "


Hope sombody can help me ...

Regards

Gopi (gchavali@polycom.com)
RE: Unexpected error on page .... [ In reply to ]
Hi ,
>
> I'm encountering this message on a particular page ... with a
> subroutine
> &dbconnect which is in a lib.pl file and i have written something
> like this
> ..
>
> [.- require "/apps/util/lib.pl"; &dbconnect; $sysdate=`date
> '+%Y%m%d%H%M'`; $sth =$dbh->prepare("select * from news where newsid =
> '$rel' and $sysdate >newsdate"); $sth -> execute; $head = $sth -> {NAME};
> $dat = $sth -> fetchall_arrayref; -]
>
> And this error message comes up very rarely but if i refresh the
> page then
> i get the output ... The following is the error message
>

Do you have this require in more then one page? I guess yes. The problem is
that the dbconnect is compiled in the namespace of the first page that
require the lib and require will not load the lib.pl a second time, so the
next page that tries to access dbconnect, get the undefined error, because
it's defined in the first page namespace and in the second page namespace.

The solution is to put the subs in an special namespace e.g.

package mylib ;

at the top of lib.pl and call mylib::dbconnect

Gerald


-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------