Hi,
I don't know if your question has been answered yet. I see two problems:
I think that the error is fairly clear on how to correct it. You can fix it
by either destroying the statement handle (a good way is to use "my" and
then when it leaves its scope it's automatically destroyed) or use:
$resultado->finish;
when you are done with the statement (this will require fewest changes to
your code).
Once you fix that you will probably still get a 500 Server Error unless you
print out the HTML header. Since you are using CGI.pm, you do that by
saying:
print header;
before you print anything else.
I hope this helps (I've inserted the lines below in your code, too),
marco
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 16, 2001 5:23 PM
> To: [EMAIL PROTECTED]
> Subject: help, help
>
>
> I runnig on Linux Red Hat 7,
>
>
> #!/usr/bin/perl -w
>
> #$|=1;
> # Utilizamos el módulo DBI para PostgreSQL
> use DBI;
> use CGI qw(:standard);
> use strict;
>
> # HTML code
print header; #added
> print "<HTML>";
> print "<HEAD>";
> print "<TITLE>Prueba de Postgres y Perl con DBI y DBD::PG</TITLE>";
> print "</HEAD>";
> print "<BODY>";
> print "<H1>Base de Datos de Soporte Internet Cancun</H1>";
>
> my ($dbdato, $dbuser, $dbpass, $conn, $sql, $resultado, $ntuplas,
> $ncampos);
> my ($r, $c, @arenglon);
>
> # param to open data base
> $dbdato = 'intercun';
> $dbuser = '';
> $dbpass = '';
>
> # make connection
> #$conn =
> DBI->connect('dbi:Pg:dbname=intercun;host=agustin.cancun.com.mx') or die
> $DBI::errstr;
> $conn = DBI->connect('dbi:Pg:dbname=intercun') or die $DBI::errstr;
>
> # SQL statement.
> $sql = "SELECT clientes.id_usuario, clientes.nombre, clientes.username
> FROM clientes WHERE nombre='Carlos'";
>
> # more html
> print "Sentencia SQL:<P>";
> print "<code>$sql </code><HR>";
> print "</P>";
>
> # we'll display
> print "<TABLE BORDER='1' CELLSPACING='0' CELLPADDING='3'>";
> print "<TH BGCOLOR='#0099FF' COLSPAN='7'>Listado de la Tabla
> Clientes</TH>";
> print "<TR><TH>id_usuario</TH><TH>nombre</TH><TH>username</TH></TR>";
>
>
> # make the query
> $resultado = $conn->prepare($sql) or die $DBI::errstr;
> $resultado->execute;
>
> # how many rows
> $ntuplas = $resultado->rows;
>
> # Cantidad de columnas o campos
> $ncampos = $resultado->{NUM_OF_FIELDS};
> # $ncampos = 2;
>
> # Recuperamos los datos
> # Primero renglón por renglón...
> for $r (0 .. ($ntuplas - 1)) {
> @arenglon = $resultado->fetchrow();
> print "<TR>";
>
> # Luego columna por columna...
> for $c (0 .. ($ncampos - 1)) {
> print "<TD>$arenglon[$c]\t</TD>";
> }
> print "</TR>";
> }
> print "</TABLE></CENTER><P>";
> print "</BODY>";
> print "</HTML>";
$resultado->finish; #added
> # disconnect
> $conn->disconnect;
>
> # End of CGI
>
> but doen't work on HTML,
> On text mode i see this error:
> disconnect (DBI::db=HASH(0x8218450)) invalidates 1 active statement.
> Either destroy statement handles or call finish on them before
> desconnecting at ./prueba.pl line 71
>
> what i'm doing wrong
>
>
> Tank in Advance
>