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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts

    Perl MySQL 500 internal Server Error

    The code does what it is supposed to do, but every time I got an "500 Internal Server Error".

    Any clue?

    Code:
    #!/usr/bin/perl
    
    use strict;
    use DBI();
    
    # Connect to the database.
    my $dbh = DBI->connect("DBI:mysql:database=xx;host=localhost",
                   "xx", "xx",{'RaiseError' => 1});
    
    # Insert something into the table 'OA':
    
    $dbh->do(
    
    "INSERT INTO OA (pi_fname, pi_lname, pi_inst, pi_email, pi_phone) 
    VALUES (?, ?, ?, ?, ?)", 
    
    undef, 
    
    'Yuhe', 'OuYang', 'Illinois', 'yliu@illinois.edu', '(456) 789-1234'
    
    );
    
    
    # Disconnect from the database.
    $dbh->disconnect();
    It is kind of weird but once I move the sub program into my main program, the error message disappeared it self. Thank you all for the help.
    Last edited by camaross; 07-08-2012 at 04:48 PM.

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    There's nothing in the code you posted to indicate that this is a cgi script, so it looks like you're leaving out a lot of details that we need to be able to help you.

  • Users who have thanked FishMonger for this post:

    camaross (07-08-2012)

  • #3
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Thank you for the reply.

    I swear I did not leave out one thing for the code. I am just using these codes to test how to work with Mysql using PERL.

    If this should not be a cgi, which file extension should I use? Sorry but I am a newbie to PERL. Thanks.

    Quote Originally Posted by FishMonger View Post
    There's nothing in the code you posted to indicate that this is a cgi script, so it looks like you're leaving out a lot of details that we need to be able to help you.

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Well, the error message you posted is a cgi error mesage. So, if you're not running this script in a cgi context, then I can't explain your error. If, however, you are running this in a cgi context, then your script generated some output before printing the html header.

  • Users who have thanked FishMonger for this post:

    camaross (07-08-2012)


  •  

    Posting Permissions

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