Hie,
I have this Pear-DB problem whereby I cant seem to get all the command in my php except those concerning DB function and template funtions to work. For example, I cant even get the
print "hello"; statement to work! I cant use this as well:
$varName = $_GET["valueFromPrevPhp"];
Since i cant get the values from GET method, it displayed ALL the information out instead of filtering
I was just wondering, could it be that Pear-DB doesnt suppose php command? Cannot be right? Here is the edited part of my code
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Wines</title>
</head>
<body><pre>
<?php
require_once "DB.php";
require_once "HTML/Template/IT.php";
require "db.inc";
$dsn = "mysql://{$username}:{$password}@{$hostName}/{$databaseName}";
// Open a connection to the DBMS
$connection = DB::connect($dsn);
// $connection = mysql_connect(...);
if (DB::isError($connection))
die($connection->getMessage());
//this part is not printed
print "hello";
//the $regionName is not assigned to any val as well
$regionName =$_GET["regionName"];
// Start a query ...
$query ="SELECT wine_name
FROM wine, winery, region
winery.winery_id = wine.winery_id AND
region.region_id = winery.region_id";
// (Run the query on the winestore through the connection
$result = $connection->query($query);
if (DB::isError($result))
die ($result->getMessage());
// Create a new template, and specify that the template files are
// in the subdirectory "templates"
$template = new HTML_Template_IT(".");
// Load the customer template file
$template->loadTemplatefile("query_result.tpl", true, true);
// While there are still rows in the result set, fetch the current
// row into the array $row
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
// Work with the customer block
$template->setCurrentBlock("ROWS");
// Assign the row data to the template placeholders
$template->setVariable("WINENAME", $row["wine_name"]);
// Parse the current block
$template->parseCurrentBlock();
}
// Output the web page
$template->show();
// Find out how many rows are available
$rowsFound =$result->numRows();
// Report how many rows were found but here also cant work print "{$rowsFound} records found matching your criteria<br>";
// end of function
?>
</pre>
</body>
</html>