Jump to content

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


arturoms

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!
Link to comment
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.