DeveloperSide.NET Forums
July 18, 2019, 08:12:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: perl scripts malfunction  (Read 8312 times)
0 Members and 1 Guest are viewing this topic.
man_pio
Member
*
Posts: 2


View Profile
« on: April 16, 2005, 11:25:04 AM »

Hi,

I have an issue with my scripts which goes thus:
I use Nvu html editor to design a form but when I click on the submit button, instead of the script running the script itself is displayed on another page.
I have allowed .cgi scripts in apache but it still gave the same error.

Please what am I doing wrong???
thanks in advance
Pious
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #1 on: April 16, 2005, 05:17:46 PM »

Sounds like your "cgi" script has a bad or no "shebang" line...
http://www.devside.net/web/config/cgi

You might also need to 'script-alias' that dir under Apache.
And have PHP or Perl setup correctly.
Check Apache's error.log file.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
man_pio
Member
*
Posts: 2


View Profile
« Reply #2 on: April 17, 2005, 02:32:39 PM »

hi,
thanks for your reply. I configured apache as stipulated in the link but still got the same error. here is a copy of my script pls. kindly edit and let me know wher I've gone wrong. I would have added the config of the httpd.conf file but it's too large to be pasted into this window. thanks.

#!/usr/bin/perl -w
                                                       
use CGI qw(:standard);
use DBI;

#setup database connection variables
$db = "weblinks";
$host = "localhost";
$user = "pious";
$password = "smokey";
                                                                             
#WEB form
print header;
print start_html('WEBLINKS DISPLAY');
print start_form,
      p
      "URL", textfield('url'),
      p
      "DESCRIPTION", textfield('description'),
      p,
      submit(-value=>"SUBMIT"),
      end_form,
      hr;

#Get Month information
my @month = ("01", "02", "03", "04", "05",
   "06", "07", "08", "09", "10",
   "11", "12");
                                                                               
#Get the date and time info
my ($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear,
   $DayOfWeek, $DayOfYear, $IsDST) = localtime(time);
# Fix the year for post-Y2K
my $Year = $ShortYear + 1900;
my $EntryDate = "$Year:$month[$Month]:$DayInMonth";
my $EntryTime = "$Hours:$Minutes:$Seconds";
                                                                               
#Create variable for form
my $URL = param('url');
my $DESCRIPTION = param('description');                                        

#ensure that text fields are filled
if (param('url') && param('description'))
{
print " ";
}
elsif (param() && param('description'))
{
print "Please enter URL!!";
}
elsif (param('url') && param())
{
print "Please enter DESCRIPTION!!";
}
else
{
print " ";
}

#connect to Database
my $dbh=DBI->connect("DBI:mysql:database=$db:host=$host", $user, $password) or die "Can't connect to database:$DBI::errstr\n";

#inserting entries
$dbh->do("INSERT IGNORE INTO link_info (URL, DESCRIPTION, DATESTAMP, TIMESTAMP) VALUES(?,?,?,?)", undef, (param('url'), param('description'), $EntryDate, $EntryTime));

$dbh->do("ALTER IGNORE TABLE link_info ADD UNIQUE URL (URL, DESCRIPTION)");

$dbh->do("DELETE FROM link_info WHERE URL = ' ' OR DESCRIPTION = ' '");

my $state = "SELECT * FROM link_info ORDER BY link_id DESC";
my $sth = $dbh->prepare($state);
$sth->execute( );
                                                                               
$sth->bind_columns ( undef,\link_id, \$URL, \$DESCRIPTION, \$EntryDate, \$EntryTime );
                                                                               
while ( $sth->fetchrow_array( ) ) {
if (param('url') && param('description'))
{
         print start_html(),
             p td($URL),
               td("<a target=_blank href=http://$URL>$DESCRIPTION</a>"),
               td($EntryDate),
               td($EntryTime),
           end_html;
}
}
$sth->finish( );
$dbh->disconnect();
exit;
Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #3 on: April 17, 2005, 05:19:00 PM »

If the source code of the script is displayed, its not a script problem.  Its a configuration problem.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!