...

View Full Version : 500 Error Help



smcgilvray
06-21-2009, 12:00 AM
I have the following script and I am getting the dreaded 500 error. Any help would be grateful.



#!/usr/bin/perl

require DBI;
use DBI;

$DBHOST = "localhost";
$DBNAME = "autoresponder";
$TABLENAME = "user";
$DBUSER = "teamrenew";
$DBPASS = "*********";

print "Content-type: text/html \n\n";

read(STDIN, $data, $ENV{'CONTENT_LENGTH'});

($cNum, $provider, $subs)=split(/&/,$data);
$cNum=~s/.*=//;
$cNum=~s/\-//g;
$cNum=~s/\.//g;
$cNum=~s/%28//g;
$cNum=~s/%29//g;
$provider=~s/.*=//;
$provider=~s/%40/@/;
$subs=~s/.*=//;
$name=~s/.*=//;
$fk_account=~s/.*=//;
$cellemail="$cNum$provider,";

$dbcall = DBI->connect("DBI:mysql:$DBNAME;$BDHOST",$DBUSER,$DBPASS) ||
die "We are not connected to database $DATABASE \n\n Error: $DBI::err : $DBI::errstr ";

if ($subs eq 'sub')
{
subscribe();
}
else
{
unsubscribe();
}

print "<br>Executed ...<br>$data<br>";

$dbcall->disconnect();
$statementhandle->finish();




sub subscribe
{
$sqlstatement="INSERT INTO $TABLENAME (email, name)
VALUES ('$cellemail','$name';

$statementhandle = $dbcall->prepare($sqlstatement);

$statementhandle->execute
|| die print
"<br><br><h2>Number already exists....redirecting to home page\!</h2><br>
<META HTTP-EQUIV='REFRESH' CONTENT='3;url=http://www.greatcareerplan.com/tr/'>";

print << "EOD";
<META HTTP-EQUIV="REFRESH" CONTENT="0;url=http://www.greatcareerplan.com/tr/index.php?option=com_content&view=article&id=74">
EOD
}

sub unsubscribe
{
$sqlstatement="DELETE FROM $TABLENAME WHERE email='$cellemail'";

$statementhandle = $dbcall->prepare($sqlstatement);

$statementhandle->execute || die print
"<br><br><h2>Your Number Is Not There To Remove....redirecting to home page\!</h2><br>
<META HTTP-EQUIV='REFRESH' CONTENT='3;url=http://www.greatcareerplan.com/tr/'>";

print << "EOD";
<META HTTP-EQUIV="REFRESH" CONTENT="0;url=http://www.greatcareerplan.com/tr/index.php?option=com_content&view=article&id=75">
EOD
}


Thank you,

Sean McGilvray

FishMonger
06-21-2009, 01:11 AM
Start by changing the beginning of the script to this, and fix the errors that are pointed out, starting with the first one.



#!/usr/bin/perl

use warnings;
use strict;
use DBI;
use CGI;
use CGI::Carp qw(fatalsToBrowser);


Errors that begin like this: "Global symbol '$DBHOST' requires explicit package name" generally means that you need to declare the var with the my keyword, like this:

my $DBHOST = "localhost";

smcgilvray
06-21-2009, 04:28 PM
I did as you said and it is still giving a 500 error. Any other suggestions?



#!/usr/bin/perl

use warnings;
use strict;
use DBI;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $DBHOST = "localhost";
my $DBNAME = "autoresponder";
my $TABLENAME = "user";
my $DBUSER = "teamrenw";
my $DBPASS = "************";

print "Content-type: text/html \n\n";

read(STDIN, $data, $ENV{'CONTENT_LENGTH'});

($cNum, $provider, $subs)=split(/&/,$data);
$cNum=~s/.*=//;
$cNum=~s/\-//g;
$cNum=~s/\.//g;
$cNum=~s/%28//g;
$cNum=~s/%29//g;
$provider=~s/.*=//;
$provider=~s/%40/@/;
$subs=~s/.*=//;
$name=~s/.*=//;
$fk_account=~s/.*=//;
$cellemail="$cNum$provider,";

$dbcall = DBI->connect("DBI:mysql:$DBNAME;$BDHOST",$DBUSER,$DBPASS) ||
die "We are not connected to database $DATABASE \n\n Error: $DBI::err : $DBI::errstr ";

if ($subs eq 'sub')
{
subscribe();
}
else
{
unsubscribe();
}

print "<br>Executed ...<br>$data<br>";

$dbcall->disconnect();
$statementhandle->finish();




sub subscribe
{
$sqlstatement="INSERT INTO $TABLENAME (email, name)
VALUES ('$cellemail','$name';

$statementhandle = $dbcall->prepare($sqlstatement);

$statementhandle->execute
|| die print
"<br><br><h2>Number already exists....redirecting to home page\!</h2><br>
<META HTTP-EQUIV='REFRESH' CONTENT='3;url=http://www.greatcareerplan.com/tr/'>";

print << "EOD";
<META HTTP-EQUIV="REFRESH" CONTENT="0;url=http://www.greatcareerplan.com/tr/index.php?option=com_content&view=article&id=74">
EOD
}

sub unsubscribe
{
$sqlstatement="DELETE FROM $TABLENAME WHERE email='$cellemail'";

$statementhandle = $dbcall->prepare($sqlstatement);

$statementhandle->execute || die print
"<br><br><h2>Your Number Is Not There To Remove....redirecting to home page\!</h2><br>
<META HTTP-EQUIV='REFRESH' CONTENT='3;url=http://www.greatcareerplan.com/tr/'>";

print << "EOD";
<META HTTP-EQUIV="REFRESH" CONTENT="0;url=http://www.greatcareerplan.com/tr/index.php?option=com_content&view=article&id=75">
EOD
}

smcgilvray
06-21-2009, 04:33 PM
I say that I have BDHOST in this line



$dbcall = DBI->connect("DBI:mysql:$DBNAME;$BDHOST",$DBUSER,$DBPASS) ||


But even when I fixed it I still get the 500 error?

FishMonger
06-21-2009, 04:56 PM
The lines I had you add will provide info that will help track down the problem(s).

What is the complete error message?

FishMonger
06-21-2009, 05:51 PM
Your script has a number of problems, but before I help you fix those problems, we need to determine if the web server is actually executing your script. If it isn't, then the starting point would be to fix that problem. The complete error message will tell us where to start.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum