Hello:
I am using one cgi/perl scripts which works perfect when I use with mysql host name as "localhost". But now I already change my hosting service and now it doesn't work. So, I need to replace mysql.neureal.com in stead local host. But I am not sure where I have to change. Here is the file:
-----------------------------------------------------------------
##########################################
## Create a connection to the database. ##
##########################################
sub Create_DB_Connection{
use DBI;
$DSN = "DBI:mysql:database1";
$user = "admin";
$pw = "adminonly";
$dbh = DBI->connect($DSN,$user,$pw)
|| die "Cannot connect: $DBI::errstr\n" unless $dbh;
return;
} # End of Create_DB_Connection subroutine.
##########################################
##########################################
## Executes the SQL command and then ##
## returns to the calling area of the ##
## program. ##
##########################################
sub Do_SQL{
eval{
$sth = $dbh->prepare($SQL);
}; # End of eval
# Check for errors.
if($@){
$dbh->disconnect;
print "Content-type: text/html\n\n";
print "An ERROR occurred! $@\n<P>";
exit;
} else {
$sth->execute;
} # End of if..else
return ($sth);
} # End of Do_SQL subroutine
#################################################################
####################################
### Filter - Gets rid of ###
### characters that screw up the ###
### program. ###
####################################
sub filter{
$_[0]=~s/\'/\\\'/g;
$_[0]=~s/\;//g;
return $_[0];
} # End of filter subroutine
#################################################################
sub parse {
my (@pairs, $pair, $name, $value);
if (uc($ENV{'REQUEST_METHOD'}) eq "POST"){read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});}
else{$buffer = $ENV{'QUERY_STRING'};}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C", hex($1))/eg;
$IN{$name} = $value;
}
}
sub HTMLdie {
local($msg,$title)= @_ ;
$title || ($title= "CGI Error") ;
print <<EOF;
<html><head>
<title>$title</title>
</head><body>
<h1>$title</h1>
<h4>$msg</h4>
</body></html>
EOF
exit ;
}
sub LoadHeader {
open(FILE, "header.html");
$header = join('', <FILE>);
close(FILE);
}
sub LoadFooter {
open(FILE, "footer.html");
$footer = join('', <FILE>);
close(FILE);
}
1; # Required or won't work!-----------------------------------------------------------------
Thanks in advance.
Sincerely yours,
Rana
I am using one cgi/perl scripts which works perfect when I use with mysql host name as "localhost". But now I already change my hosting service and now it doesn't work. So, I need to replace mysql.neureal.com in stead local host. But I am not sure where I have to change. Here is the file:
-----------------------------------------------------------------
Code:
##########################################
## Create a connection to the database. ##
##########################################
sub Create_DB_Connection{
use DBI;
$DSN = "DBI:mysql:database1";
$user = "admin";
$pw = "adminonly";
$dbh = DBI->connect($DSN,$user,$pw)
|| die "Cannot connect: $DBI::errstr\n" unless $dbh;
return;
} # End of Create_DB_Connection subroutine.
##########################################
##########################################
## Executes the SQL command and then ##
## returns to the calling area of the ##
## program. ##
##########################################
sub Do_SQL{
eval{
$sth = $dbh->prepare($SQL);
}; # End of eval
# Check for errors.
if($@){
$dbh->disconnect;
print "Content-type: text/html\n\n";
print "An ERROR occurred! $@\n<P>";
exit;
} else {
$sth->execute;
} # End of if..else
return ($sth);
} # End of Do_SQL subroutine
#################################################################
####################################
### Filter - Gets rid of ###
### characters that screw up the ###
### program. ###
####################################
sub filter{
$_[0]=~s/\'/\\\'/g;
$_[0]=~s/\;//g;
return $_[0];
} # End of filter subroutine
#################################################################
sub parse {
my (@pairs, $pair, $name, $value);
if (uc($ENV{'REQUEST_METHOD'}) eq "POST"){read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});}
else{$buffer = $ENV{'QUERY_STRING'};}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("C", hex($1))/eg;
$IN{$name} = $value;
}
}
sub HTMLdie {
local($msg,$title)= @_ ;
$title || ($title= "CGI Error") ;
print <<EOF;
<html><head>
<title>$title</title>
</head><body>
<h1>$title</h1>
<h4>$msg</h4>
</body></html>
EOF
exit ;
}
sub LoadHeader {
open(FILE, "header.html");
$header = join('', <FILE>);
close(FILE);
}
sub LoadFooter {
open(FILE, "footer.html");
$footer = join('', <FILE>);
close(FILE);
}
1; # Required or won't work!
Thanks in advance.
Sincerely yours,
Rana