Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: 500 Error Help

  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    500 Error Help

    I have the following script and I am getting the dreaded 500 error. Any help would be grateful.

    Code:
    #!/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

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Start by changing the beginning of the script to this, and fix the errors that are pointed out, starting with the first one.

    Code:
    #!/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:
    Code:
    my $DBHOST = "localhost";

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did as you said and it is still giving a 500 error. Any other suggestions?

    Code:
    #!/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
    }

  • #4
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I say that I have BDHOST in this line

    Code:
    $dbcall = DBI->connect("DBI:mysql:$DBNAME;$BDHOST",$DBUSER,$DBPASS) ||
    But even when I fixed it I still get the 500 error?

  • #5
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    The lines I had you add will provide info that will help track down the problem(s).

    What is the complete error message?

  • #6
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •