In the beginning of your script, put:

print "Content-type: text/html\n\n";

This is because the browser need to know what content type is being printed, and in the shell all is the same, so you don't need it. Anyway, any web page you request is declared with a content type, but this is automatically done by HTTP.



--------------
Bob Erinkveld (Webmaster Insane Hosts)
www.insane-hosts.net
MSN: [EMAIL PROTECTED]





From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: script runs in console but not in browser
Date: Mon, 9 Dec 2002 15:26:35 +0200

Sorry about the vague topic, don't know how to describe the problem.

My code runs OK in the console and does what it is meant to do. In the
browser it doesn't die or give any errors, but only does about half of
what it is meant to do before it magically stops with no errors.

If you look at the below code, it gets as far as:
while ( ( my $store ) =  $sth->fetchrow_array ) {
        print "<OPTION VALUE=\"$store\" >$store</OPTION>\n";
}
Now it falls over during this loop, there about 250 records it needs to
print and stops randomly between the first record and sometimes near the
last. but there are no error messages, the script thinks that it has
done everything. I hope this makes some sense, as i have no idea how to
troubleshoot this problem and all the FAQs and docs mentioned in
perlfaq? don't seem to have answers.

I'm running Perl 5.6.0 with apache 1.3

TIA
Merritt


sub fetch
{
        my $dsn   = 'dbi:Pg:dbname=foo;host=172.30.2.253;port=5432';
        my $username = "bar";
        my $password = "baz";
        # make connection
        my $dbh = DBI->connect ($dsn, $username, $password, {
                PrintError => 1,
                RaiseError => 0
} )
        or warn "Can't connect to the PG database: $DBI::errstr\n";
# SELECT store
my $sth = $dbh->prepare( "
        SELECT  store_number FROM store ORDER BY store_number
        " ) or warn "SELECT: $DBI::errstr<BR>";
$sth->execute( ) or warn "EXEC: $DBI::errstr<BR>";
print "Store Number:";
print "<SELECT NAME=\"store\">\n";
print "<OPTION SELECTED></OPTION>\n";
while ( ( my $store ) =  $sth->fetchrow_array ) {
        print "<OPTION VALUE=\"$store\" >$store</OPTION>\n";
}
print "</SELECT><BR>\n";
# Disconnect from Pg DB
$dbh->disconnect or warn "Disconnection Failed: $DBI::errstr<BR>";
}
<< attach3 >>

_________________________________________________________________
Chatten met je online vrienden via MSN Messenger. http://messenger.msn.nl/


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to