#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    9
    Rep Power
    0

    postgresql and cgi


    hi
    I have a postgresql database and i am able to query it and read it into the perl program.

    For my application, i need to take the input from a html form .... compute using perl...... look up the postgres database and then display the result again on the web. I am getting internal server error when i try to do this. Can anybody please tell me what does it mean and how can I solve it? Im attaching my code here...

    #!/usr/bin/perl

    use strict;
    use DBI;

    use CGI qw/:all/;

    $ENV{'PGUSER'}= 'abcd';
    $ENV{'PGPORT'}='7777';
    $ENV{'PGDATABASE'}='movies';

    my $tapeid=param("tapeid");
    my $dbh = DBI->connect("dbi:Pg:dbname=movies","abcd","xyzzz",{printError=> 1})
    or die "Cant connect to postgreSQL: $DBI::errstr ($DBI::err)\n";

    my $sth = $dbh->prepare("SELECT * FROM rentals WHERE tapeid='$tapeid'");

    if(defined($sth)) {
    if($sth->execute()){
    get_results($sth);

    }
    }


    $dbh->disconnect();

    sub get_results
    {
    my $i =0;
    my @set=0;
    my $sth=shift;
    my $x=0;
    while(my $vals=$sth->fetchrow_arrayref()){
    foreach my $val (@$vals) {
    $set[$i] = $val;
    $i = $i+1;
    }
    }


    foreach my $x (0..($i-1)){
    print p "\n the set for $x is $set[$x] \n";
    }
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    373
    Rep Power
    12
    What is the exact error? And was postmaster started accepting requests on any port? (default is 5432) you can check if in postgresql.conf the option is set to true, it's the first option. Or run pg_ctl status and it will show what options it was started with. a -i indicates it was started accepting tcp/ip connections
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    9
    Rep Power
    0
    I tried using pg_ctl status command and i got this:
    pg_ctl: postmaster is running (pid: 26600)
    Command line was:
    /usr/bin/postmaster

    I am not sure what does it mean. Moreover what am i supposed to look in postgresql.conf. I am really amateur as far as unix and postgres is concerned... can you please help me with that?
    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo