Chris Lambrou wrote:
>
> Hello,
>
> I know I am doing something wrong here, just can't figure it
> out. I am using the following PERL code to connect to my local
> mysql server:
>
> -------------------------
> print "Content-Type: text/html\n\n";
> use Mysql;
> $dbh = Mysql->Connect('localhost', 'z100' ,'Z100' ,'z100club+');
>
> if (not $dbh) {
> print "Could Not connect to database.\n";
> print "Reason: $Mysql::db_errstr";
> } else {
> print "Connected";
> }
>
> -------------------------
> This prints the following on the web page:
>
> Could Not connect to database.
> Reason:
>
> ( The $Mysql::db_errstr string is EMPTY!!! )
>
> Notes:
> 1. MySql Version: 3.21.33b.
> The server was started with a plain "mysqld" command
>
> 2. I've manually added the above user, pass*d to the user and db tables.
> From the command line, I can login using the above credentials
> just fine.
>
> 3. If I change the password to anything else in the PERL code
> above, I get this in $Mysql::db_errstr:
> "Access denied for user: 'Z100@localhost' (Using password: YES)"
> Which is what it should be in the $Mysql::db_errstr.
>
> Can someone please help?
>
> Thanks.
> Chris.
>
If you really have to use Mysql module, read the docs carefully on how
to check for errors - it appears to me that you actually connect, but
the condition not $dbh is true regardless.
Or, better, use the DBI interface.
--
Sasha Pachev
http://www.sashanet.com/ (home)
http://www.direct1.com/ (work)