Hi everyone, I'm trying to connect to my MySQL databse with a perl script. This is on a GoDaddy shared server. Here is what I have:
#!/usr/bin/perlml use cPanelUserConfig; use 5.010; use strict; use warnings; use CGI::Carp qw/fatalsToBrowser/; print "Content-type: text/html\n\n"; #B1. Database name, table name, user name, and password #respectively. User name and password are case sensitive. my $dbase="***"; my $tablename="***"; my $username="***"; my $mysqlpassword="***"; #These two should not need modified unless connecting to MySQL on #a remote server or to a database platform other than MySQL. my $hostname="localhost"; my $databaseserver="mysql"; use DBI; say "Perl MySQL Connect Demo"; # MySQL database configuration my $DSN = "dbi:mysql:$dbase:$hostname"; my $dbh = DBI->connect( $DSN, $username, $mysqlpassword ) or die "$DBI +::errstr"; say "Connected to the MySQL database.";
When I run this, I get a 500 internal server error. However, when I comment out line 30, the DBI->connect line, the script runs and the output says: "Perl MySQL Connect Demo Connected to the MySQL database." I have checked and the DBI and the MySQL modules are installed. I've searched and searched online, and tried a bunch of different formats, and can't get anything to work. Can anyone help? Thank you!

In reply to 500 internal server error when connecting to mysql database by mcfarnell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.