golemicata Posted July 12, 2012 Share Posted July 12, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/265563-help-me-non-static-method-db/ Share on other sites More sharing options...
zPlus Posted July 12, 2012 Share Posted July 12, 2012 Non-static method DB::connect() should not be called statically.... Just do what it says... $db = new DB(); $db->connect(); or something like that... Quote Link to comment https://forums.phpfreaks.com/topic/265563-help-me-non-static-method-db/#findComment-1361046 Share on other sites More sharing options...
ignace Posted July 12, 2012 Share Posted July 12, 2012 The PEAR packages are unfortunately written like that. To get rid of the strict error messages alter error_reporting to error_reporting(E_ALL & ~(E_STRICT | E_NOTICE)); Quote Link to comment https://forums.phpfreaks.com/topic/265563-help-me-non-static-method-db/#findComment-1361050 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.