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

Help! refer to a friend script with captcha code
Hi guys, I am posting on here in desperate need for some help with an ongoing search I have been doi

Simple MySQL query...
Hello,
How could I do a mysql query that does this: SELECT * WHERE date/time < 5minutes ag

Security Exception on pages using AJAX
I am getting the exception: attempted to perform an operation not allowed by the security policy on

Using mysql_real_escape_string for displayed content
On my website users can input data into a textarea and it will store it in the mysql database. But,

PHP header help!
Hi all I am trying to get this php page to refresh every 5 seconds on my phone which is an aastra 48

1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.


In some case, there will be 100+ of the

getAlexaRank($url) function not working
I have made a function to get alexa rank
the site is here: http://mytestsite.rack111.com/1

Multidimensional $_POST
Hello

How to get a single array from array of array (2 - dimension).
For example I have a

IF Statement & Two Tables With Different Echoes
I'm retrieving two tables in a single query using UNION ALL, like so:

Code: $query = "SE

Auto-populating dropdowns and multiple forms.
Here's what I have so far:

First drop down = select a state (works)
This populates the sec

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