MySQL Forums
Forum List  »  Perl

Modify DB script to connect
Posted by: Mork Heng
Date: March 04, 2009 11:53PM

i have migrate to a multiple domains server which doesn't have cgi-bin for each domain n doesn't support ODBC. So i have to modify a script written long ago by someone (top part of the script the help line ask me to modify):

use strict;
use DBI;
use CGI::Carp qw(fatalsToBrowser);

my $dbstring = 'dbi:ODBC:Castle_de_France';
#my $dbstring = 'dbi:mysql:db';
my $dbstring = 'dbi:mysql:castle';
my $user = 'cdef;
my $pass = 'france';

my $IsMSQL = 1;

sub IsMySQL(){ return $IsMSQL; }

sub getLastInsertId(){
my $lastInsertIdSQL;

if (&IsMySQL()) {
$lastInsertIdSQL = 'select last_insert_id() id';
} else {
$lastInsertIdSQL = 'select @@identity id';
}

my $rs = query_select($lastInsertIdSQL);
return $rs->fetchrow_hashref->{'id'};
}

sub openDatabase(){
return DBI->connect($dbstring, $user, $pass,
{RaiseError => 1, PrintError => 1});

...and they given me this to add but i don't know where to add, my MySQL is an address: castleoffrance.ipowermysql.com and user is cdef database name is db so i should add this somewhere to what is given also?

$db_connection = mysql_connect ($dbhost,$dbusername,$dbpassword) or die("Could not connect to DB");
mysql_select_db ($database) or die("Could not find DB");

anyone can help, tkz...

Options: ReplyQuote


Subject
Written By
Posted
Modify DB script to connect
March 04, 2009 11:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.