THRAK has asked for the wisdom of the Perl Monks concerning the following question:
I have a MySQL database that has a password that is "some@thing". If I connect to the DB using using an escaped string or collect the password as a CGI parameter it connects without a problem. I've found that it chokes on the password when I read it from a file. As a psuedo-code snippet:
This causes the DB connection to fail because of the password. If I do this, it then works:
I've tried $password = quotemeta($password) but that didn't work either.
I'm stumped and this is holding up my progress. How do I go about escaping the "@" character so MySQL is happy?
Thanks - THRAK
$_ = "host|db_name|user|some@thing"; ($host, $database, $username, $password) = split /\|/; $dbh = DBI->connect("DBI:mysql:$database:$host", $username, $password) + || error('login');
This causes the DB connection to fail because of the password. If I do this, it then works:
$_ = "host|db_name|user|some@thing"; ($host, $database, $username, $password) = split /\|/; $password = "some\@thing"; $dbh = DBI->connect("DBI:mysql:$database:$host", $username, $password) + || error('login');
I've tried $password = quotemeta($password) but that didn't work either.
I'm stumped and this is holding up my progress. How do I go about escaping the "@" character so MySQL is happy?
Thanks - THRAK
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Escaping MySQL password
by sutch (Curate) on Mar 26, 2001 at 18:13 UTC | |
Re: Escaping MySQL password
by ChOas (Curate) on Mar 26, 2001 at 18:15 UTC | |
Re: Escaping MySQL password
by kilinrax (Deacon) on Mar 26, 2001 at 18:17 UTC | |
Re: Escaping MySQL password
by davorg (Chancellor) on Mar 26, 2001 at 18:19 UTC | |
by THRAK (Monk) on Mar 26, 2001 at 18:39 UTC | |
Re: Escaping MySQL password
by THRAK (Monk) on Mar 26, 2001 at 18:49 UTC | |
Re: Escaping MySQL password
by Masem (Monsignor) on Mar 26, 2001 at 19:24 UTC |
Back to
Seekers of Perl Wisdom