The server I'm on is using Apache 1.3.3 for FreeBSD 2.2.7, MySQL 3.22, perl 5.002 and
DBI-0.93. The database has 5 tables each with a primary key column, "id" that is identical
for all 5 tables. When I telnet in and use the command line, the query works fine and
returns the expected results. When I connect with DBI, only the beginning of the HTML page
is printed. No data, no error, nothing else is printed, not even the bottom of the HTML
page. I would appreciate any suggestions. I have successfully queried 1 table at a time
using DBI, but the bind_columns still doesn't work right.
query-using only 3 of the tables
SELECT categories.id, categories.ILTCIBA,
FROM categories, demographics, products
ORDER BY demographics.city, demographics.company;
perl using DBI:
use CGI qw(param);
print "Content-type: text/html\n\n";
my $CATEGORY = param("category");
my $STATE = param("state");
(print beginning of HTML page)
my $sql_query = "SELECT ";
$sql_query .= "categories.id, categories.$CATEGORY ";
$sql_query .= "demographics.company, demographics.city, ";
$sql_query .= "demographics.state, products.upgrade ";
$sql_query .= "FROM categories, demographics, products ";
$sql_query .= "WHERE categories.$CATEGORY=1 ";
$sql_query .= "AND demographics.state=$STATE ";
$sql_query .= "AND categories.id=products.id ";
$sql_query .= "AND demographics.id=products.id ";
$sql_query .= "ORDER BY demographics.city, demographics.company";
my $dbh = DBI->connect('DBI:mysql:mydatabase:myserver',
die "Database connection not made: $DBI::errstr";
my $sth = $dbh->prepare($sql_query) ||
die "Unable to prepare $sql_query: $DBI::errstr\n";
my ($id, $category, $company, $city, $state, upgrade);
$sth->bind_columns(undef, \$id, \$category, \$company, \$city, \$state, \$upgrade);
$search_results .= "$company<BR>\n"
$search_results .= "$city<BR>\n"
$search_results .= "$state<BR>\n"
$search_results .= "$upgrade<BR>\n"
(print remainder of HTML page)