Jump to content

Archived

This topic is now archived and is closed to further replies.

arturoms

Fatal error: Call to a member function on a non-object. Pls help me!

Recommended Posts

Hi,
I am not very good at PHP and am trying to install a script but I have this problem that I just can't figure out...

Code snippet:

<?php
// UTF-8 helper functions
require(dirname(__FILE__) .'/includes/utf8.php');

include('Mail.php');

// Translation
require(dirname(__FILE__) .'/includes/php-gettext/streams.php');
require(dirname(__FILE__) .'/includes/php-gettext/gettext.php');
$input = new FileReader(dirname(__FILE__) .'/locales/'. $locale .'.mo');
$l10n = new gettext_reader($input);

// Standard wrappers for xgettext
function T_($text) {
global $l10n;
return $l10n->translate($text);
}

function T_ngettext($single, $plural, $number) {
global $l10n;
return $l10n->ngettext($single, $plural, $number);
}


PHP throws 'Fatal error: Call to a member function on a non-object ..
functions.inc.php on line 16' at me whenever I request this page.
Code at line 16: return $l10n->translate($text);

What am I doing wrong?

Thanks!

Share this post


Link to post
Share on other sites
[quote author=arturoms link=topic=112492.msg456610#msg456610 date=1161655496]
Hi,
I am not very good at PHP and am trying to install a script but I have this problem that I just can't figure out...

Code snippet:

<?php
// UTF-8 helper functions
require(dirname(__FILE__) .'/includes/utf8.php');

include('Mail.php');

// Translation
require(dirname(__FILE__) .'/includes/php-gettext/streams.php');
require(dirname(__FILE__) .'/includes/php-gettext/gettext.php');
$input = new FileReader(dirname(__FILE__) .'/locales/'. $locale .'.mo');
$l10n = new gettext_reader($input);

// Standard wrappers for xgettext
function T_($text) {
global $l10n;
return $l10n->translate($text);
}

function T_ngettext($single, $plural, $number) {
global $l10n;
return $l10n->ngettext($single, $plural, $number);
}

Thanks!
[/quote]

One of two things.  Either $l10n is not a valid class or the translate function doesn't exist inside of the class.  One of the two include files has a class definition called l10n, and all functions inside that class are defined as $l10n->function() - so inside one of those files the translate function is missing, or the file that it does exist in isn't uploaded. Make sense?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.