CGI Help

Поиск
Список
Период
Сортировка
От Jeff
Тема CGI Help
Дата
Msg-id 97bn9p$bne$1@news.tht.net
обсуждение исходный текст
Ответы Re: CGI Help  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi,

I have a cgi script that runs fine under command-line

But when execute from a client browser, I get CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:

It seems like it is not able to connect to the host.

here's what I have in my pg_hba.conf
local        all                                           trust
host         all         127.0.0.1     255.255.255.255     trust
test         all         192.168.38.0    255.255.255.0     trust

executing from client browser
http://www.test.com/cgi-bin/test.cgi

int main()
{
  char *queryString, *contentTypeFromPost, *contentTypeLength;
  int icontentLength, i, j;
  char database[100], *p;
  char contentType[] = "text/html", TheDomainName[100], thisfax[25];
  char today[81];
  ItemList items, *orderlst = NULL, *ip;
  char        state_code[3];                          /* holds state code
entered by user
  char        query_string[256];                      /* holds constructed
SQL query */
  PGconn     *conn;                                   /* holds database
connection */
  PGresult   *res;                                    /* holds query result
*/

  /* setup the html document header */
  printf("Content-Type: %s\n\n", contentType);
  conn = PQconnectdb("dbname=template1");                  /* connect to the
database */

  if (PQstatus(conn) == CONNECTION_BAD)               /* did the database
connection fail?
  {
    printf("Connection to database failed.\n");
    printf("%s", PQerrorMessage(conn));
    return(1);
  }

  strcpy(query_string,                               /* create an SQL query
string */
          "SELECT * FROM cities");

  res = PQexec(conn, query_string);                   /* send the query */

  if (PQresultStatus(res) != PGRES_TUPLES_OK)         /* did the query fail?
*/
  {
    printf("SELECT query failed.\n");
            PQclear(res);
            PQfinish(conn);
            return(1);
  }

  for (i = 0; i < PQntuples(res); i++)                /* loop through all
rows returned */
  {
     printf("%s\n", PQgetvalue(res, i, 0));          /* print the value
returned */
     printf("%s\n", PQgetvalue(res, i, 1));          /* print the value
returned */
     printf("%s\n", PQgetvalue(res, i, 2));          /* print the value
returned */
  }
  PQclear(res);                                       /* free result */

  PQfinish(conn);                                     /* disconnect from the
database */

return(0);

}



В списке pgsql-general по дате отправления:

Предыдущее
От: John Madden
Дата:
Сообщение: Re: Re: local mailing lists
Следующее
От: gambits
Дата:
Сообщение: Lan Connection