LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-26-2004, 06:01 AM   #1
amit_28oct
Member
 
Registered: Feb 2004
Posts: 31

Rep: Reputation: 15
Problem (Perl + PostgreSQL)


I connected postgreSQL database with perl using code given below
But this code is working only from command prompt & when I am logged in to postgreSQL.
But I want to view the o/p in Netscape. I am using Apache 2.0.40 & Redhat9 OS. Pls make the required modification in code. or if I have to do some enviornment setting tell me.
I am typeing http: //localhost /cgi-bin/beers.pl in Netscape.
Code is as follows.

#!/usr/bin/perl
# beers.pl - my first perl data base script!
use DBI;
$dbh = DBI->connect('dbi:Pg:dbname=test', 'postgres', 'post');
$sth = $dbh->prepare("SELECT * from statename");
$rv = $sth->execute;
while (my @row_ary = $sth->fetchrow_array)
{print " $row_ary[0] $row_ary[1]\n";}
$sth->finish;
undef $sth;
$dbh->disconnect;
undef $dbh;

Regards
amit
 
Old 03-26-2004, 07:47 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
this should get you going.

look at CGI in

www.perldoc.com

Code:
#!/usr/bin/perl 
# beers.pl - my first perl data base script!
use DBI;
use CGI qw( :standard );

print   header(),
        start_html("Beers.pl");

print hr;
print "<pre>\n";

     $dbh = DBI->connect('dbi:Pg:dbname=test', 'postgres', 'post');
       $sth = $dbh->prepare("SELECT * from statename");
        $rv = $sth->execute;
         while (my @row_ary = $sth->fetchrow_array)
        {print " $row_ary[0] $row_ary[1]\n";}
                         $sth->finish;
                         undef $sth;
                         $dbh->disconnect;
                         undef $dbh;

print "</pre>\n";
print end_html;
 
Old 03-27-2004, 03:18 AM   #3
amit_28oct
Member
 
Registered: Feb 2004
Posts: 31

Original Poster
Rep: Reputation: 15
I tried the code given by u. But when I tried to run it by http://localhost/cgi-bin/beers.pl I was unable to see any o/p in browser. but a single straight line was displayed at the line one of browser. Remember I am able to connect perl to Postgre only when I am on postgre prompt not from anywhere else.

waiting for reply
regards
 
Old 03-29-2004, 03:28 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
look in /var/apache/logs/error_log
to see what's happening.
(this name may be wrong, from memory but it will be somewhere in /var)


do "tail -f /var/apache/logs/error_log", try the cgi
and see what the errors are.


billy
 
Old 03-29-2004, 04:37 AM   #5
amit_28oct
Member
 
Registered: Feb 2004
Posts: 31

Original Poster
Rep: Reputation: 15
Following is the file /var/log/httpd/error_log.
But I am not getting what to do now.


[Sun Mar 28 15:38:50 2004] [notice] Digest: generating secret for digest authentication ...
[Sun Mar 28 15:38:50 2004] [notice] Digest: done
[Sun Mar 28 15:38:51 2004] [notice] Apache/2.0.40 (Red Hat Linux) configured -- resuming normal operations
[Sun Mar 28 17:39:26 2004] [warn] child process 2205 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:26 2004] [warn] child process 2206 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:26 2004] [warn] child process 2207 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:26 2004] [warn] child process 2208 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:26 2004] [warn] child process 2209 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:26 2004] [warn] child process 2210 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:26 2004] [warn] child process 2211 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:26 2004] [warn] child process 2212 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2205 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2206 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2207 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2208 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2209 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2210 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2211 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:27 2004] [warn] child process 2212 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2205 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2206 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2207 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2208 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2209 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2210 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2211 still did not exit, sending a SIGTERM
[Sun Mar 28 17:39:28 2004] [warn] child process 2212 still did not exit, sending a SIGTERM
[Mon Mar 29 15:49:27 2004] [notice] Digest: generating secret for digest authentication ...
[Mon Mar 29 15:49:27 2004] [notice] Digest: done
[Mon Mar 29 15:49:28 2004] [notice] Apache/2.0.40 (Red Hat Linux) configured -- resuming normal operations
[Mon Mar 29 15:51:53 2004] [error] [client 127.0.0.1] Premature end of script headers: emp.pl
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
postgresql problem eduac Linux - Software 0 08-31-2005 06:45 AM
Postgresql Problem mitrship Programming 3 07-28-2005 12:09 AM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
PostgreSQL Problem r0ck Slackware 8 11-26-2004 11:02 AM
postgresql -odbc & postgresql-jdbc installation kjsubbu Linux - Software 0 06-19-2003 02:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration