
dopple
New User
Aug 31, 2009, 8:04 AM
Post #1 of 3
(5228 views)
|
DBI->connect causing running of cgi script to fail
|
Can't Post
|
|
Hi. First time posting here so please bear with me. I have a problem where a script will run fine in the terminal, but doesn't work when called as a cgi script in my browser. When I run it I get an error in the apache log as so [Mon Aug 31 15:27:31 2009] [error] [client 192.168.158.162] at /usr/local/apache2/cgi-bin/assyst.pl line 20 Line 20 is the DBI->connect method. I can output text before the DBI->connect statement but anything after it will not work. One other thing that may be related is I get an "out of memory" error when I run this in the terminal but it finishes to completion.
#!/usr/bin/perl -w ############################## # Assyst.pm # 31/08/2009 # Connects to and queries assyst database ############################## use strict; use warnings; use DBI; print "Content-type: text/html\n\n"; my($DBTYPE)="DBI:Oracle"; my($HOST)="xxxxxxxxx"; my($SID)="xxxx"; my($PORT)="xxxxxx"; my($USER)="xxxxxxx"; my($PASS)="xxxxx"; my($CSTRING)="${DBTYPE}:host=${HOST};sid=${SID};port=${PORT}"; my($DBH)=DBI->connect($CSTRING, $USER, $PASS,{RaiseError=>1}) or die "$DBI::errstr"; my($UID); my($EMAIL_ADD)=""; my($SQL)=qq{ select staff_no,email_add from sa.usr T where staff_no IS NOT NULL AND stat_flag='n' }; my($STH)=${DBH}->prepare(${SQL}); ${STH}->execute(); ${STH}->bind_columns(undef, \${UID}, \${EMAIL_ADD}); print "TEST"; my($HEADER)=qq{<html> <head> <title>Assyst Search</title> </head> <body> <table> <tr> <th>UID</th><th>Email</th> </tr> }; print "${HEADER}"; while(${STH}->fetch()) { print "\t\t\t<tr>\n"; print "\t\t\t\t<td>${UID}</td><td>"; if (${EMAIL_ADD}) { print "${EMAIL_ADD}</td>\n"; }else{ print "</td>\n"; } print "\t\t\t</tr>\n"; } ${STH}->finish(); ${DBH}->disconnect; my($FOOTER)=qq{ </table> </body> </html>}; print "${FOOTER}\n"; exit(0);
|