MissouriTiger
Programmer
Please someone tell me if I'm doing something wrong.
I'm trying to connect to a remote database from a CGI script written in Perl. I keep getting a "cannot connect" error.
I've asked the host of the DB server to check the permissions, and if I'm using the right port #, and they say everything is fine.
I've tried this a million times. Any help is most welcome! Please have a look at my code below.
sub save_user_profile
{
my ($user, $password, $dsn, $dbHandle, $queryString, $stmtHandle);
$user = "norris";
$password = "secret";
#I tried the following line both with and without
#the port number.
$dsn = "DBI:mysql:norris:jlxlinux.com";
#Default port = 3306.
#Open connection to MySQL database.
$dbHandle = DBI->connect($dsn, $user, $password)
or die("Database connection error: $DBI::errstr"
#Create SQL statement.
$queryString = "INSERT INTO MEMBERS (User_ID, Password, First_Name, Last_Name, Email_Address) " +
" VALUES ($username, $password, $firstName, $lastName, $email);";
#Use statement handle to prepare and execute SQL statement.
$stmtHandle = $dbHandle->prepare($queryString);
$stmtHandle->execute
or die "Could not execute SQL statement ... maybe invalid?";
$stmtHandle->finish();
$dbHandle->disconnect();
}# End save_user_profile
If you think the problem is on their end, can anyone recommend a more reliable place to host my DB (free or cheap, since I'm just learning)?
Thanks in advance for any help/advice,
Greg _______________________________________
Constructed from 100% recycled electrons
I'm trying to connect to a remote database from a CGI script written in Perl. I keep getting a "cannot connect" error.
I've asked the host of the DB server to check the permissions, and if I'm using the right port #, and they say everything is fine.
I've tried this a million times. Any help is most welcome! Please have a look at my code below.
sub save_user_profile
{
my ($user, $password, $dsn, $dbHandle, $queryString, $stmtHandle);
$user = "norris";
$password = "secret";
#I tried the following line both with and without
#the port number.
$dsn = "DBI:mysql:norris:jlxlinux.com";
#Default port = 3306.
#Open connection to MySQL database.
$dbHandle = DBI->connect($dsn, $user, $password)
or die("Database connection error: $DBI::errstr"
#Create SQL statement.
$queryString = "INSERT INTO MEMBERS (User_ID, Password, First_Name, Last_Name, Email_Address) " +
" VALUES ($username, $password, $firstName, $lastName, $email);";
#Use statement handle to prepare and execute SQL statement.
$stmtHandle = $dbHandle->prepare($queryString);
$stmtHandle->execute
or die "Could not execute SQL statement ... maybe invalid?";
$stmtHandle->finish();
$dbHandle->disconnect();
}# End save_user_profile
If you think the problem is on their end, can anyone recommend a more reliable place to host my DB (free or cheap, since I'm just learning)?
Thanks in advance for any help/advice,
Greg _______________________________________
Constructed from 100% recycled electrons