Re: HTML_AJAX and MDB2
| From: | Joshua Eichorn | Date: | Tue, 03 Apr 2007 21:23:18 +0000 |
| Subject: | Re: HTML_AJAX and MDB2 | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26994@lists.php.net to get a copy of this message | ||
The first thing I would try is making a test script for that class so you can see things working without AJAX involved.
Another thing to look at is how your handling errors. Those die messages aren't caught by HTML_AJAX so they can't be shown by an error handler on the browser side.
-josh
T A wrote:
Hello, I'm trying to use an MDB2 object in My Ajax class which serves the requests. This is my autoserver.php <? require_once 'HTML/AJAX/Server.php'; class AutoServer extends HTML_AJAX_Server { // this flag must be set for your init methods to be used var $initMethods = true; // init method for my hello world class function initHelloWorld() {require_once 'HelloWorld.class.php'; require_once 'MDB2.php'; require_once 'const.php';$hello =new HelloWorld($db); //$this->registerClass($hello); for php4 $this->registerClass($hello,'helloworld',array('checkuser','deposit'));} } $server = new AutoServer(); $server->handleRequest(); ?> My $db is created in const.php and as you can see I pass it as a parameter to HelloWorld's constructor. This is my HelloWorld.class.php file <?php error_reporting(E_ALL); session_start("ours"); $dir = "../.."; $sep=PATH_SEPARATOR; set_include_path($dir."/includes/pear".$sep.$dir."/includes".$sep. $dir."/includes/functions".$sep. $dir."/includes/classes");require_once 'MDB2.php'; //MDB2 before const.php require_once 'site_const.php'; //this is the way you set the PATH and include files in THIS FILE which is included //from before.php via autoserver.php require_once 'const.php'; require_once 'functions_draw_site.php'; require_once 'functions.php'; //$user_id = $_SESSION["sess_user_id"]; class HelloWorld {function HelloWord($db){ $this->db= $db;}function deposit(){ $row=$this->db->queryRow("SELECT * FROMnewsWHEREid='1'");if (PEAR::isError($this->db)){ die($this->db->getMessage() . ', ' . $this->conn->getUserInfo() ); }if (PEAR::isError($row)){ die($row->getMessage() . ', ' . $row->getUserInfo() ); } return $row["text"]; }} However i don't get any output when i call the deposit() function( and deposit is really called). When i try to call deposit without any $db object it is ok. Any ideas?Thanks. _________________________________________________________________ Don't just search. Find. Check out the new MSN Search! http://search.msn.com/