Strict Standards: Non-static method DB::parseDSN() should not be called statically in C:\xampp\php\PEAR\DB.php on line 520
Strict Standards: Non-static method DB::isError() should not be called statically in C:\xampp\php\PEAR\DB.php on line 551
Strict Standards: Non-static method DB::isError() should not be called statically in C:\xampp\php\PEAR\DB.php on line 557
Strict Standards: Non-static method DB::isError() should not be called statically in C:\xampp\htdocs\chaperter10\results_generic.php on line 38
Strict Standards: Non-static method DB::isManip() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\DB\common.php on line 2195
Strict Standards: Non-static method DB::isError() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\DB\common.php on line 1217
Strict Standards: Non-static method DB::isError() should not be called statically in C:\xampp\htdocs\chaperter10\results_generic.php on line 48
1. ItemType: t-shirt
size: L
Price: 5.00
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>xxx</title>
</head>
<body>
<h1>xxx</h1>
<?php
// create short variable names
$searchtype=$_POST['searchtype'];
$searchterm=$_POST['searchterm'];
$searchterm= trim($searchterm);
if (!$searchtype || !$searchterm)
{
echo 'You have not entered search details. Please go back and try again.';
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
// set up for using PEAR DB
require('DB.php');
$user = 'xx';
$pass = 'xx';
$host = 'localhost';
$db_name = 'xxx';
// set up universal connection string or DSN
$dsn = "mysql://$user:$pass@$host/$db_name";
// connect to database
$db = DB::connect($dsn, true);
// check if connection worked
if (DB::isError($db))
{
echo $db->getMessage();
exit;
}
// perform query
$query = "select * from item where ".$searchtype." like '%".$searchterm."%'";
$result = $db->query($query);
// check that result was ok
if (DB::isError($result))
{
echo $db->getMessage();
exit;
}
// get number of returned rows
$num_results = $result->numRows();
// display each returned row
for ($i=0; $i <$num_results; $i++)
{
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
echo '<p><strong>'.($i+1).'. ItemType: ';
echo htmlspecialchars(stripslashes($row['ItemType']));
echo '</strong><br />size: ';
echo stripslashes($row['size']);
echo '<br />Price: ';
echo stripslashes($row['price']);
echo '</p>';
}
// disconnect from database
$db->disconnect();
?>
</body>
</html>

Can you help me?


