Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Help me Non-Static method DB::....

General discussions related to php

Moderators: macek, egami, gesf

Help me Non-Static method DB::....

Postby golemicata » Thu Jul 12, 2012 3:26 am

Strict Standards: Non-static method DB::connect() should not be called statically in C:\xampp\htdocs\chaperter10\results_generic.php on line 35

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?
golemicata
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Jul 11, 2012 5:05 am

Re: Help me Non-Static method DB::....

Postby johnj » Thu Jul 12, 2012 6:32 am

Instead of DB::connect(), change it to
$db = new DB();
$db->connect();
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Help me Non-Static method DB::....

Postby golemicata » Fri Jul 13, 2012 12:37 am

johnj wrote:Instead of DB::connect(), change it to
$db = new DB();
$db->connect();



after exchange


Warning: Missing argument 1 for DB::connect(), called in C:\xampp\htdocs\chaperter10\results_generic.php on line 36 and defined in C:\xampp\php\PEAR\DB.php on line 518

Notice: Undefined variable: dsn in C:\xampp\php\PEAR\DB.php on line 520

Strict Standards: Non-static method PEAR::raiseError() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\DB.php on line 540

Notice: Undefined variable: dsn in C:\xampp\php\PEAR\DB.php on line 542

Strict Standards: Non-static method DB::errorMessage() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\DB.php on line 965

Strict Standards: Non-static method DB::isError() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\DB.php on line 688

Strict Standards: Non-static method PEAR::getStaticProperty() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\PEAR.php on line 871

Strict Standards: Non-static method DB::isError() should not be called statically in C:\xampp\htdocs\chaperter10\results_generic.php on line 39

Fatal error: Call to undefined method DB::query() in C:\xampp\htdocs\chaperter10\results_generic.php on line 47
golemicata
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Jul 11, 2012 5:05 am

Re: Help me Non-Static method DB::....

Postby johnj » Fri Jul 13, 2012 2:08 am

looks like your include file/pear db is in conflict with the php version you are using. So, when you fix one error, it will throw another one in the next line.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron