Thank you both for these ideas. I'm sorry if I'm not including all the information I should - I'll continue to do the best I can. I checked my dbase, tablename, username, and password. They only contain letters or numbers. The password does have a % sign, but when I printed it out it seems to be ok. Would that cause a problem? I also tried all of the formats for the DSN variable as your link suggested. You can see them in my code commented out. None of them changed the output. So here is my updated code:
#!/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 $hostname = "localhost:3306"; #my $hostname = "p3plcpnl1204.prod.phx3.secureserver.net"; my $databaseserver="mysql"; use DBI; say "Perl MySQL Connect Demo"; # MySQL database configuration #my $DSN = "dbi:mysql:$dbase:$hostname"; #my $DSN = "DBI:mysql:$dbase"; #my $DSN = "DBI:mysql:database=$dbase;host=$hostname"; my $DSN = "DBI:mysql:database=$dbase;host=$hostname"; my $dbh = DBI->connect( $DSN, $username, $mysqlpassword ); my $dbh = ""; if ($dbh) { say "Connected to the MySQL database."; } else { say "Catastrophe! Connection failure with DSN '$DSN', pass '$mysql +password', user '$username': $DBI::errstr +"; }
When I run this code as is, the output is:
500 Internal Server Error Please forward this error screen to cowlitzcountycemeterydistrict6.inf +o's WebMaster. The request was not completed. The server met an unexpected condition. cowlitzcountycemeterydistrict6.info/cgi/test2.pl (port 80)
When I comment out the DBI->connect line, line number 35, the output is:
Perl MySQL Connect Demo Catastrophe! Connection failure with DSN 'DBI: +mysql:database=***;host=localhost', pass '***', user '***': +
I was able to find an error log under cpanel, even though GoDaddy told me I only had access to PHP error logs. The error I am seeing is:
/usr/bin/perlml: relocation error: /home/b3mtw1376jad/perl5/lib/perl5/ +x86_64-linux-thread-multi/auto/DBD/mysql/mysql.so: symbol mysql_optio +ns4, version libmysqlclient_18 not defined in file libmysqlclient.so. +18 with link time reference
I assume this error in the error log is the answer to my problems? But I'm not sure how to fix it. We are on a shared hosting plan. Does this mean I need the server admin to do something? I found this article related to this issue: https://dev.mysql.com/doc/refman/8.0/en/perl-support-problems.html

In reply to Re^2: 500 internal server error when connecting to mysql database by mcfarnell
in thread 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.