Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using variable instead of string in DBI->Connect() doesnt work

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

Newbie here to perl and mysql.

I want to pass the database, user, password to the
DBI->connect() method but it doesnt work.

the troubled code looks like this..

use strict;
use DBD::mysql;

# Create list of variable
my $database = "test";
my $user = 'joe';
my $password = 'joe';
#create database handle
my $db_hndle = DBI->connect("DBI:mysql:database=$database",$user,$password) || die "Didn't connect to database";

#####Error#####
DBI->connect(database=wehookup_users) failed: Access denied for user: 'joe
@localhost' (Using password: YES) at C:\Program Files\Komodo\MyWork\mysql\mysqlprac.pl line 30

yes the password is correct! and when I don't use variables it works fine.

THanx in advance
 
my $database = "test" and the error message (database=wehookup_users) do not match.

Also, try my $database = 'test' and change "DBI:mysql:database=$database" to "DBI:mysql:database=".$database

Chad. ICQ: 54380631
online.dll
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top