Código:
Setup.inc<? require('includes/setup.inc'); $smarty = new Smarty_PcDb; $smarty->assign('template_dir', 'templates/default'); if($_GET['action'] == "failed") { $smarty->display('templates/default/regist/failed.tpl'); } else if($_GET['action'] == "new") { $smarty->display('templates/default/regist/new.tpl'); } else if($_GET['action'] == "forget") { $smarty->display('templates/default/regist/forget.tpl'); } else if($_GET['action'] == "save") { if(!empty($_POST['enviarReg'])) { $hayEmail = $pcdb_sql->query($db, "SELECT `email` FROM $db[prefix]_users WHERE `email` = '".$_POST['regEmail']."'", 4); if ($hayEmail[0] == $_POST['regEmail']) { class errors { function setError($id) { $smarty->assign('error_titulo','2'); } } $errors = new errors; $errors->setError(0); $smarty->display('templates/default/error.tpl'); } else { $smarty->display('templates/default/regist/done.tpl'); $pcdb_sql->query($db, "INSERT INTO $db[prefix]_users VALUES('','".$_POST['regUser']."','".$_POST['regPass']."', '".$_POST['regNombre']."','".$_POST['regDireccion']."','".$_POST['regCP']."','".$_POST['regCuit']."', '".$_POST['regTelefono']."','".$_POST['regEmail']."','".$_POST['regEmpresa']."','2000-11-15','0')", 0); } } else { $smarty->display('templates/default/index.tpl'); } } else if(empty($_GET['action'])) { $smarty->display('templates/default/index.tpl'); } ?>
Código:
<? require('db.inc'); require('Smarty/Smarty.class.php'); $pcdb_sql->connect($db); class Smarty_PcDb extends Smarty { function Smarty_PcDb() { // Constructor de la clase $this->Smarty(); $this->template_dir = '/www/vhosts/myscene/smarty/tpl/'; $this->compile_dir = '/www/vhosts/myscene/smarty/tpl_c/'; $this->config_dir = '/www/vhosts/myscene/smarty/configs/'; $this->cache_dir = '/www/vhosts/myscene/smarty/cache/'; $this->assign('app_name','PcDb'); } } ?>
Paso a explicar:
Yo utilizo el sistema de templates Smarty. El error lo obtengo al tratar de hacer una clase que cuando alguien intenta registrarse, si por ejemplo el email ya existe, me facilite algunas cosas.
Código:
La clase es más larga, pero ahi sinteticé lo que me da error.class errors { function setError($id) { $smarty->assign('error_titulo','titulo lindo'); } }
El error que obtengo es
[Sat Jun 26 21:11:04 2004] [error] PHP Fatal error: Call to a member function on a non-object in /www/vhosts/myscene/registracion.php on line 25
Si no usaron smarty no se preocupen, aca el error es mas conceptual, algo de las clases que estoy ignorando
Muchas gracias de antemano