in reply to DBD DBI Mysql Connect
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBD DBI Mysql Connect
by Umdurman (Acolyte) on Sep 10, 2017 at 21:47 UTC | |
|
Re^2: DBD DBI Mysql Connect
by 1nickt (Canon) on Sep 11, 2017 at 14:08 UTC |