Hello Umdurman,
Similar question has been asked before Can't call method "prepare" on an undefined value.
Most likely you are not connecting to your database. Enter a validation error on your connection, sample of untested code bellow:
Change this:
$Dbh = DBI->connect($DbConnectionInfo,$DbUserid,$DbPasswd);
To this:
my $dbh = DBI->connect($DbConnectionInfo,$DbUserid,$DbPasswd, { RaiseE +rror => 1 });
From DBI documentation:
$dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1, AutoCommit => 0 });
Update: I would also suggest to use error handling on your prepare statements also, if the connect to DB is good then the error is coming from the prepare statement.
Sample of untested code:
$Sth = $Dbh->prepare("SELECT RegNum FROM $DbUsers ORDER BY RegNum DESC + LIMIT 1") or die "Can't prepare: ", $dbh->errstr;
Update 2: Very useful tutorial / tips and tricks with DBI Tricks with DBI.
Hope this helps, BR.
In reply to Re: DBD DBI Mysql Connect
by thanos1983
in thread DBD DBI Mysql Connect
by Umdurman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |