cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PERL use SQLite connect - Query can't find tables

Pressured to change from old host to cPanel. Created a new data base. connect using MySQL failed so changed to recommended SQLite, connect appears to work, $dbh has a value. A sample $dbh = DBI::db=HASH(0x116d728)

When I do a query -

# RUN A QUERY;
my $rowcnt='';
my $Query = "SHOW TABLE STATUS";
my $sth = $dbh->prepare($Query);
$rowcnt = $sth->execute();
if ($rowcnt eq '0E0') {print "row cnt = 0 <br><br>";}

 

, I get following err msg:

DBD::SQLite::db prepare failed: near "SHOW": syntax error at dbi_test.cgi line 30.
Can't call method "execute" on an undefined value at dbi_test.cgi line 31.

I need help

 

1 REPLY 1

here is program that quits at prepare line

 

#!/usr/bin/perl
use cPanelUserConfig;
use strict;
close STDERR;
open STDERR, ">>../myerrorlog.txt";
print STDERR "\nStarting dbi test cgi\n";
use DBI;
print "Content-type: text/html\n\n";

# DATA BASE VARIABLES;
my $dbn = "DBI:SQLite:database=family,host=localhost,port=3306";
my $userid = 'tom';
my $password = 'crellcpw1';

# OPEN DATA BASE;
my $dbh = DBI->connect($dbn, $userid, $password);
print "data base handle = $dbh\n\n "; #debug;

# RUN A QUERY;
my $rowcnt='';
my $Query = "SELECT * FROM `user`";
my $sth = $dbh->prepare($Query);
$rowcnt = $sth->execute();
if ($rowcnt eq '0E0') {print "row cnt = 0 \n\n";}
print "rowcnt = $rowcnt\n\n"; #debug;

$sth->finish();
$dbh->disconnect();
exit;

 

see error msg above