eternitysoft
Mitglied
Bräuchte hilfe beim Parsen eines Templates aus einer Datenbank (Smarty) wenn jemand Ahnung dann bitte hilfe <.<
fehler:
Fatal error: Call to a member function on a non-object in .../testdb2.php on line 43
PHP:
<?php session_start ();
require('inc/function.php');
require('config.php');
$absoluter_pfad = dirname(__FILE__);
define('SMARTY_DIR', $absoluter_pfad.'/smarty/');
require(SMARTY_DIR.'Smarty.class.php');
$connect = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$connect)
{
die('Verbindung nicht möglich : ' . mysql_error());
}
else
{
$select = mysql_select_db($dbname);
if (!$select){
die('Konnte datenbank nicht auswählen: ' . mysql_error());
mysql_close($connect);
}
else
{
// put these function somewhere in your application
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
{
// do database call here to fetch your template,
// populating $tpl_source
$sql = new SQL;
$sql->query("select content
from templates
where id='2'");
if ($sql->num_rows) {
$tpl_source = $sql->record['tpl_source'];
return true;
} else {
return false;
}
}
// register the resource name "db"
$smarty->register_resource("db", array("db_get_template"));
$datum ="22.3.89";
$smarty->assign("date",$datum);
$smarty->display("db:index.tpl");
mysql_close($connect);
}
}
?>
fehler:
Fatal error: Call to a member function on a non-object in .../testdb2.php on line 43