Hi Guys,
Moving one of my sites from traditional control panel to CPanel
This site uses a MySQL db
Successfully created and imported the old data via the CPanel
Trying to figure out the correct perl cgi connection (host setup is different from the tradiational control panel)
Here's my perl cgi
sub SetupMySQLDB{
use DBI;
$db = "godaddydbname";
$host = 'localhost:3306';
$user = $db; # your Database name is the same as your account name.
$pwd = "dbuserpassword";
$dbcon = "dbi:mysql:$db:$host";
print "Content-type: text/html\n\n";
print "connecting<br>";
$dbh = DBI->connect( $dbcon, $user, $pwd);
print "connected<br>";
}
If I comment out the $dbh = line, it runs fine.
Uncommented, it fails to connect.
any ideas with what's wrong here?
TIA.
Solved! Go to Solution.
I was able to get a GoDaddy ticket to solve this one.
My code was just fine, the problem was the perl call.
Old code header:
#!/usr/bin/perl
$|=1;
Updated code header:
#!/usr/bin/perlml
use cPanelUserConfig;
$|=1;
My test code worked just fine using the updated code header.
Thanks GoDaddy, Brian and your team. Good job.
Update:
After talking to GoDaddy support, they advise that I should not include the port (?) 3306 and that the User should be added to the DB in CPanel, user added and port removed from code.
So now the code looks like this:
sub SetupMySQLDB{
use DBI;
$db = "godaddydbname"; #edited out actual db name
$host = 'localhost';
$user = 'DBUserName'; #edited out actual username
$pwd = "dbuserpassword"; #edited out actual password
$dbcon = "dbi:mysql:$db:$host";
print "Content-type: text/html\n\n";
print "connecting: >>> $dbcon, $user, $pwd<br>";
$dbh = DBI->connect( $dbcon, $user, $pwd);
print "connected<br>";
}
Same condition.
Checked the error logs and it shows the error is in the $dbh = DBI line.
I was able to get a GoDaddy ticket to solve this one.
My code was just fine, the problem was the perl call.
Old code header:
#!/usr/bin/perl
$|=1;
Updated code header:
#!/usr/bin/perlml
use cPanelUserConfig;
$|=1;
My test code worked just fine using the updated code header.
Thanks GoDaddy, Brian and your team. Good job.