mcfarnell has asked for the wisdom of the Perl Monks concerning the following question:
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!#!/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.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 500 internal server error when connecting to mysql database
by kcott (Archbishop) on May 19, 2023 at 07:09 UTC | |
by mcfarnell (Initiate) on May 20, 2023 at 17:22 UTC | |
|
Re: 500 internal server error when connecting to mysql database
by hippo (Archbishop) on May 19, 2023 at 10:16 UTC | |
by mcfarnell (Initiate) on May 20, 2023 at 17:21 UTC | |
by hv (Prior) on May 20, 2023 at 18:24 UTC | |
by kcott (Archbishop) on May 20, 2023 at 23:58 UTC |