Working with Global Variables


Posted on 16th Feb 2014 07:03 pm by admin

hi, I'm not really sure why the following code is returning a "Call to a member function getBanners() on a non-object" error message.

Code:
var $_model;
Did you know?Explore Trending and Topic pages for more stories like this.

function display ($tpl=null)
{
$this->_model = &$this->getModel();
global $option,$mainframe, $_model;

$Banners = $_model->getBanners();


$this->assignRef('Banners', $Banners);
parent::dislay($tpl);
}

if I replace "$Banners = $_model->getBanners();" with "$Banners = $this->_model->getBanners();" it works fine, I'm trying to shorten the code though.
No comments posted yet

Your Answer:

Login to answer
340 Like 15 Dislike
Previous forums Next forums
Other forums

php/mysql auto logout after 2 hour and reset password
Hi all,

This I hope will make sense. I've the following code which when a user logins in, cr

retrieving policy name inside the function called by this particular policy
Hi there,

I've playing around with dbms_rls package, trying to set up some security repo

Calander layout
Hi i know this sounds like a simple question but i cant find the answer to it anywhere i have added

update sql when refresh - php
hi
I have made a table (attachement)

the users can update the sql database using + or x bu

Exporting new records
Trying to figure out the best way to set this up.

People register my site.

Their prof

Weekly Calendar
Hi, I am looking at creating a weekly calendar. The calendar will read from Monday - Sunday. Does an

values not being entered into table
hi. I;ve created a form, so that when a user enters data into it, it gets added to a table in a data

displaying email without attracting a ton of spam
Hello,

this is maybe the wrong place to ask.
How would you display an email address on a w

Good Programming and Web Design Books
Hi,

I recived a pm today from a fellow phpfreaker regarding php books, i replied with the fo

socket makes browser hang...
I have a socket server, and I am having a problem at the moment...

A browser sends a http hea

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash