Re: how to connect database from web
Posted in 1999
--Boundary_(ID_+gc09xwY4EKiBkvpscBbhA)
Content-type: text/plain; charset=us-ascii
Content-disposition: inline
Content-transfer-encoding: 7BIT
Peary
The "grant connect to public" needs to be done by the person who has dba
rights on the database /hom/frm/tt@dbs_rm. What your program is doing is
trying to first connect to the database as "nobody" who I assume has no
rights on the database now, then trying to "grant connect to public". Since
"nobody" is not a dba for the database, the "grant connect to public" is
not his to grant. You need to run the "grant connect to public" from within
dbaccess as the Unix user who is the dba on the database (check this by
running "select username from sysusers where usertype = "D"" from
dbaccess).
HTH
Sujit
peary <peary@ms1.url.com.tw> on 05/25/99 06:39:47 PM
Please respond to peary <peary@ms1.url.com.tw>
To: informix-list@iiug.org
cc: (bcc: Sujit Pal)
Subject: Re: how to connect database from web
--Boundary_(ID_+gc09xwY4EKiBkvpscBbhA)
Content-type: text/plain; charset=iso-8859-1
Content-disposition: inline
Content-transfer-encoding: quoted-printable
Hi, Jeepee,
Yes....that's why I cannot access database on the web ....
Someone told me I have to use "grant", so I changed my program to
$ connect to '/home/frm/tt@dbs_rm' ;
$ grant connect to public;
But it still don't work , do you know what's wrong?
Peary
> I think ./add is runned by user nobody. (apache and others default)
> Check ACLs.
>
> Jeepee
>
> peary a =E9crit dans le message <7idn32$rik$1@news1.sinica.edu.tw>...=
> >Hi,
> >
> >I use Linux with Informix SE, ESQL/C, ISQL 7.20.
> >I want to run my EC program on the web browser to insert/select data=
from
> >my informix server. I can run my EC program correctly and insert the=
data
> to
> >the database. But if I run it on the web then it cannot open the
database,
> >the sqlca.sqlcode=3D-461
> >Originally, i think maybe i didn't give the program the userid and p=
wd,
> >but after i tried it's the same.....
> >Here is my EC program "add.ec".....
> >-------------------------------------
> >#include <stdio.h>
> >#include <stdlib.h>
> >#include <string.h>
> >$include sqlca;
> >
> >void main(int argc,char *argv[]){
> > char name[20],addr[40],tel[10],item_list[1024+1];
> > $char sql_insert[1024+1],pwd[15+1];
> >
> > strcpy(pwd,"mypassword");
> >
> >$ connect to '/home/frm/tt@dbs_rm' user 'peary' using $pwd=
;> >
> >/* $ database 'tt@dbs_rm'; */
> >
> > if(sqlca.sqlcode<0){
> > printf("database open error!\\n");
> > exit(0);
> > }
> >
> > strcpy(name,argv[1]);
> > strcpy(addr,argv[2]);
> > strcpy(tel,argv[3]);
> >
> > sprintf(item_list,"('%s','%s','%s')",name,addr,tel);
> > sprintf(sql_insert,"%s %s\\n","insert into base
values",item_list);
> >
> >$ prepare cur from $sql_insert;
> >$ execute cur;
> >$ free cur;> >
> >$ disconnect current;> >
> > exit(1);
> >}
> >
> >------------------------------
> >I use "esql -o add add.ec" compiled it to "add", and if i run "./add=
123
> 456
> >789"
> >under Linux, then it can connect to the database and insert the 3 da=
tas.
> >But if I run it on the web( use perl to call ec program), then it al=
ways
> >returns
> >"database open error!".
> >Here is my perl program "tt.pl"...
> >------------------------------
> >
> >#!/usr/bin/perl
> >use CGI qw/:standard :html3/;
> >use CGI::Carp qw(fatalsToBrowser);
> >use CGI::Carp qw(carpout);
> >use strict;
> >
> >require "pl_lib.pl";
> >
> >$|=3D1;
> >print "Content-type:text/html\\n\\n";
> >
> >my %FORM=3Dread_input(); #-- to analyse the form data
> >
> >print <<eof;
> > <p><h1>Thank you for your coming!!!</h1>
> > name:$FORM{'name'}<p>
> > addr:$FORM{'addr'}<p>
> > tel:$FORM{'tel'}<p>
> >eof
> >
> >print "C starts....<br>";
> >
> >my $val=3Dqx(./add $FORM{'name'} $FORM{'addr'} $FORM{'tel'})||die $!=
;
> >print "return value--$val<br>";
> >
> >print "C ends...<br>";
> >
> >--------------------------------
> >The perl script can run correctly , so the problem is database....
> >Could you help me again? Thank you~~~
> >
> >Peary
> >
> >
> >
> >
> >
> >
>
>
=
--Boundary_(ID_+gc09xwY4EKiBkvpscBbhA)--