pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Lo <jwlo@ms11.hinet.net>
To: pgsql-interfaces@postgreSQL.org
Subject: Help! DBI Pg problems.
Date: Sat, 16 Jan 1999 11:40:52 +0800
Message-ID: <36A00A43.8818D61E@ms11.hinet.net> (raw)

Hi,

I'm trying to use Postgres DBI, which is Pg, to write a simple cgi script.
But I encounter a problem, hope anyone can tell me how to do, thanks.

For example:
I have two input forms in ex.html, which names are 'id' and 'student'.
I want to insert them into 'course' table in student database by using Pg.
The script I wrote as following:

#!/usr/local/bin/perl
require 'forms-lib.pl';/* this script gets form values in HTML that I input */
use DBI;
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Data inserted</TITLE>\n";
print "</HEAD>\n";
%input = &GetFormInput();
$v1 = $input{'id'};
$v2 = $input{'student'};
$dbh = DBI->connect("dbi:Pg:dbname=student") or die $DBI::errstr;
$sth = $dbh->prepare("insert into course values('$v1', '$v2')")
     or die $DBI::errstr;
$sth->execute or  die $DBI::errstr;
print "<BODY>\n";
print "<H1>Data inserted!</H1>\n";
print "</BODY>\n";
print "</HTML>\n";

After executing this script, I just see brower's title "Data inserted",
I can't see "Data inserted!" in HTML and can't insert values into 'course'
table. I don't know how to do, would anyone tell me, thanks in advance.

Best regards,
Kevin.







Message-ID: <36A00A43.8818D61E@ms11.hinet.net>
Permalink:  ../36A00A43.8818D61E@ms11.hinet.net/
Also on:    postgresql.org/message-id/36A00A43.8818D61E@ms11.hinet.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jwlo@ms11.hinet.net
  Subject: Re: Help! DBI Pg problems.
  In-Reply-To: <36A00A43.8818D61E@ms11.hinet.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox