phpbar.de logo

Mailinglisten-Archive

[dbs] Problem mit DB - Objekten; Beispiel aus dem Buch: Web Database Application with PHP and Mysql

[dbs] Problem mit DB - Objekten; Beispiel aus dem Buch: Web Database Application with PHP and Mysql

j.kuehne at sign-tronic.ch j.kuehne at sign-tronic.ch
Die Jul 11 11:04:35 CEST 2006


Kann mir jemand weiterhelfen mit den Fehlermeldungen. Irgendwie scheint $connection keine Objekt der Klasse DB zu sein. Wobei $connection = DB::connect($dsn, true) erzeugt wird, aber eben mit der Meldung; Error: "Non-static method DB::connect() should not be called statically" (error #2048).

Vielen Dank

Gruss,Jörg




require_once "DB.php";                         
require_once "knowledge.inc";  
require_once "template-new.inc";  
         
set_error_handler("custom Handler");

global $connection;

/////////////////////////////////////////////
//start php
////////////////////////////////////////////
function setupQuery($search_eb)
{ 
  $query = "SELECT *
             FROM knowledge_db
             WHERE MATCH (autor,problem) AGAINST ('$search_eb')
             OR id = ('$search_eb') 
             OR autor = ('$search_eb')  
             OR stichwort = ('$search_eb')
             OR date_new = ('$search_eb')
             OR anlage = ('$search_eb')
     return ($query);
}

error_reporting(E_ALL);



function showKnowledges($connection, &$template)
{

 $template->setCurrentBlock()
 $template->setVariable("SUCH-KRITERIUM","Such-Kriterium: {$_SESSION["searchFormVars"]["search_eb"]}");  
 $browseString = "search_eb=" . urlencode($_SESSION["searchFormVars"]["search_eb"]);

 $query = setupQuery($_SESSION["searchFormVars"]["search_eb"]);  
//////////////////////////////////////   
 $result = $connection->query($query);
///Fatal error: Call to a member function query() on a non-object in C:\Xampp\xampp\htdocs\www2\knowledge_db\searchnew.php
//////////////////////////////////////

    if (DB::isError($result))
        trigger_error($result->getMessage(), E_USER_ERROR);
         $numRows = $result->numRows();
 
        
.
.
.
/////////////////////////////////////////////
//somewhere between the rows
/////////////////////////////////////////////
 for ( $rowCounter = 0;
            ($rowCounter < SEARCH_ROWS) &&
             $rowCounter + $_SESSION["searchFormVars"]["offset"] <  
             $result->numRows()&& 

//////////////////////////////////////
             $row = $result->fetchRow(DB_FETCHMODE_ASSOC, $_SESSION["searchFormVars"]["offset"]+$rowCounter);
///Fatal error: Call to a member function query() on a non-object in C:\Xampp\xampp\htdocs\www2\knowledge_db\searchnew.php
//////////////////////////////////////

             $rowCounter++)
      {   


.
.
.
/////////////////////////////////////////////
///at the end
/////////////////////////////////////////////
session_start();  

$template = new knowledgeTemplate(T_SEARCH, P_TITLE);
/////////////////////////////////////////////
$connection = DB::connect($dsn, true);
//Error: "Non-static method DB::connect() should not be called statically" (error #2048)
/////////////////////////////////////////////

if (DB::isError($connection))
trigger_error($connection->getMessage(), E_USER_ERROR); 

$_SESSION["searchFormVars"]["search_eb"] = 
   pearclean($_GET, "search_eb", 100, $connection); 
if (isset($_GET["offset"]))
  $_SESSION["searchFormVars"]["offset"] = 
  pearclean($_GET, "offset", 5, $connection);
else 
  $_SESSION["searchFormVars"]["offset"]=0;
showKnowledges($connection, $template);

$template->showKnowledge_db(SHOW_ALL, B_HOME | B_SEARCH); 
?>


php::bar PHP Wiki   -   Listenarchive