I have a website which is already working. I have decided to chnage my hosting company. But i am having a problem getting my perl script working.
If you click on the link below it displays a list of all proeprties:
http://www.goarealestates.com/cgi-bin/housing.pl?search=1&category=Buy&;submit=Go!!!
Within my script file, i have a statement as below which connects to the database
$dbh = db_connect($database,$user,$password);
And the function db_connect() is as below:-
sub db_connect {
($database,$user,$password) = @_;
my $h = DBI->connect("DBI:mysql:$database", $user, $password)
or printError("Unable to connect to $database" . $DBI::errstr);
return $h;
}
I have also got a db.cfg file which is as below
# script config file
$database = "shafi";
$user = "shafi";
$password ="shafi";
1;
But the present hosting provider has given an example of how to connect to the mysql database as below:-
=================================================
#!/usr/bin/perl
use DBI;
print "Content-type:text/html\n\n";
$db_handle = DBI->connect("dbi:mysql:database=dbxxxxxxxx;host=dbxxx.oneandone.co.uk;user=dboxxxxxxxx;password=xxxxxxxx")
or die "Couldn't connect to database: $DBI::errstr\n";
$sql = "SELECT * FROM puretest";
$statement = $db_handle->prepare($sql)
or die "Couldn't prepare query '$sql': $DBI::errstr\n";
$statement->execute()
or die "Couldn't execute query '$sql': $DBI::errstr\n";
while ($row_ref = $statement->fetchrow_hashref())
{
print "Name <b>$row_ref->{name}</b> has email address::<b>$row_ref->{email}</b>.<br>";
}
$db_handle->disconnect();
===================================================
The DBI->connect statement is different and deosnt seem to work. Could someone tell me how my function should change to adapt to this hsoting provider.