Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] heeeeeeeeeeeeelp meeeeeeeeeeee

From: Constantin Teodorescu <teo(at)flex(dot)ro>
To: rony khoury <rkhoury(at)apotres(dot)edu(dot)lb>
Cc: PostgreSQL Interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: [INTERFACES] heeeeeeeeeeeeelp meeeeeeeeeeee
Date: 1998-06-29 18:16:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
rony khoury wrote:
> First I have redhat linux 5.0 running on my system , with it comes
> postgresql I got these
> to run fine on my system using psql as the interface .

I would recommend you to install RedHat 5.1 and updates because it has a
lot of things improved, even PostgreSQL libraries preinstalled.

> Now I tried a two steps procedure to do so , first is to conect from C
> to postgresql , and latter to
> use C modules as cgi called from browsers .

With PHP you will mix : HTML generator, database connection and form
It's just simple. Look over my examples that I have sent to you and you
will see how.
In PHP, you will find the form variables that you have defined a
previous HTML form as local variables.
Just use them and don't even think how they have been passed.

You might get some problems trying to compile PHP with PostgreSQL
support and apache with PHP module, but reading their README's will be
just fine. Just follow them. If you have some problems, just ask.

Apache 1.3.0  + PHP 3.0  would be a good choice.
Also ,Perl cgi's would be fine.

I am giving you here an example how to get form variables in Perl and
how to connect to PostgreSQL database.


use Pg;

   $datele = <STDIN>;
   @pairs = split(/&/, $datele);
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);
      # restore blank
      $value =~ tr/+/ /;
      # restore special char
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
      # store them into associative array %VAR
      chomp $value; $value =~ s/\r//;
      $VAR{$name} = $value ;

#  preluam cimpurile transmise in variabile
   $nrfact   = $VAR{'nrfact'};
   $client   = $VAR{'client'};
   $valoare  = $VAR{'valoare'};
   $datafact = $VAR{'datafact'};
   $continut = $VAR{'continut'};
   $continut =~ s/'/\\'/g;

   ($zi,$luna,$an) = split(/\./,$datafact);
   $datafact = $luna.'-'.$zi.'-'.$an;

# Acest rind este obligatoriu pentru inceput de HTML raspuns
print "Content-type:text/html\n\n";

print <<EOM;
<TITLE>Emitere factura</TITLE>
<H1>S-a emis urmatoarea factura</H1>
Factura cu numarul : $nrfact <br>
Data emiterii : $datafact <br>
Catre clientul : $client <br>
Valoarea facturii : $valoare <br><br>


$res=PQexec($con,"select * from factemise where nrfact='$nrfact'");
if ($errmsg ne '') {
   print "<B> Eroare select verificare dubluri<br>",$errmsg;
   print "</body></html>\n";
   PQclear($res); PQfinish($con);
   exit 1;
if (PQntuples($res) > 0) {
   print "<b>Eroare : Mai exista o factura cu numarul $nrfact<b>";
   print "</body></html>\n";
   PQclear($res); PQfinish($con);
   exit 1;

$sqlcmd="insert into factemise (nrfact,datafact,client,valoare,
continut) values
#print $sqlcmd;
$errmsg = PQerrorMessage($con);
if ( $errmsg ne '' ) {
     print '<font color="#FF0000">';
     print "<b>EROARE INSERT : MESAJ = ",$errmsg,"</b></font><br>";
} else {
     print 'Inregistrarea a fost efectuata !';

print "</body></html>\n";


Constantin Teodorescu
director FLEX Consulting Braila, ROMANIA

In response to

pgsql-interfaces by date

Next:From: David HartwigDate: 1998-06-29 18:45:16
Subject: Re: [INTERFACES] scrollable cursor via odbc
Previous:From: Vince VielhaberDate: 1998-06-29 18:11:13
Subject: Re: [INTERFACES] heeeeeeeeeeeeelp meeeeeeeeeeee

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group