andibakker Posted October 26, 2009 Share Posted October 26, 2009 I am trying to learn smarty and OO Php by going through a sample application. I have downloaded everything and setup libraries. After I have instantiated my object, nothing displays. I have set error_reporting(E_ALL); In an effort to debug - I've put in the following echo statements in. echo "before instantiating"; // create guestbook object $guestbook =& new Guestbook; $guestbook->sql->query("select * from guestbook", SQL_ALL); print_r($guestbook->sql->record); echo "after instantiating "; All that displays when I run this is : Now when I run it, it only displays the following : before instantiating Please help I am also new to OO php, so this could be something very basic that I'm overlooking. I am not too sure why they use =& in the code to instantiate the object. Below is the constructor for the guestbook class. class Guestbook { public $testname = "testgbname"; // database object var $sql = null; // smarty template object var $tpl = null; // error messages var $error = null; /** * class constructor */ function Guestbook() { // instantiate the sql object $this->sql =& new GuestBook_SQL; // instantiate the template object $this->tpl =& new Guestbook_Smarty; \ and here is the Guestbook_SQL class GuestBook_SQL extends SQL { function GuestBook_SQL() { // dbtype://user:pass@host/dbname $dsn = "mysql://root:pass@localhost/guestbook"; $this->connect($dsn) || die('could not connect to database'); } } Please help, I have no idea where to go from here. I also tried to access the $guestbook->testname property, but that doesn't display anything either. Thanks Andi Quote Link to comment https://forums.phpfreaks.com/topic/179058-no-output-after-object-instantiated/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 26, 2009 Share Posted October 26, 2009 Use both of the following lines of code so that errors are both reported and displayed - ini_set("display_errors", "1"); error_reporting(E_ALL); On a development system, you should actually have these two settings in your master php.ini so that you don't need to put them into your files or remember to remove them when you put your finished code on a live server. Quote Link to comment https://forums.phpfreaks.com/topic/179058-no-output-after-object-instantiated/#findComment-944691 Share on other sites More sharing options...
andibakker Posted October 26, 2009 Author Share Posted October 26, 2009 I have added the extra line of code. Still no output on the screen other than object instantiated Quote Link to comment https://forums.phpfreaks.com/topic/179058-no-output-after-object-instantiated/#findComment-944742 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.