Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:57:24+00:00 2026-06-05T06:57:24+00:00

I am not sure why but I am getting this error Fatal error: Call

  • 0

I am not sure why but I am getting this error

Fatal error: Call to a member function update() on a non-object in /home/XXXXXXXXXXXXXXXXX/classes/core.php on line 22

On that page I have this

public function updatemongo($from,$data)
    {
        $this->db = $m->exchange_rates;
        $collection = $this->db->exchangeDB;
        $collection->update(array("from" => $from), $data);
    }

this is how I am calling this function

foreach ($currencies as $to)
 {
    if($from != $to)
    {

        $url = 'http://finance.yahoo.com/d/quotes.csv?f=l1d1t1&s='.$from.$to.'=X';
        $handle = fopen($url, 'r');

        if ($handle) {
            $result = fgetcsv($handle);
                fclose($handle);
        }

        $newdata = array('$set' => array("exchangehistory.{$result[1]}.{$result[2]}" => array("to" => $to, "rate" => $result[0], "updated" => $result[2])));
        $fetch->updatemongo($from,$newdata);

        $newdata = array('$set' => array("currentexchange" => array("to" => $to, "rate" => $result[0], "updated" => $result[2])));
        $fetch->updatemongo($from,$newdata);


    }
 }

and yes the file needing to access this is also has require_once("core.php");

Please let me know why this is not working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:57:25+00:00Added an answer on June 5, 2026 at 6:57 am

    The updatemongo() function doesn’t have access to the $m variable. Please pass it to the function like this:

    $fetch->updatemongo($m, $from, $newdata);
    

    And change your function definition to:

    public function updatemongo($m, $from, $data)
    {

    Alternatively, you can set the m property of the object to the connection after you’ve created it. For example with:

    public function __construct)
    {
        $this->m = new Mongo();
    }
    ...
    public function updatemongo($from, $data)
    {
        $this->db = $this->m->exchange_rates;
        $collection = $this->db->exchangeDB;
        $collection->update(array("from" => $from), $data);
    }
    

    Or perhaps you can just use $this->exchange_rates already above… in any case, you’re not making $m available to the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looping my object data but am getting this undefined value. Not sure why
I'm not sure why I'm getting this error, but shouldn't this code compile, since
This was working just fine, not sure what broke it, but now I'm getting
I am getting this error in all of my classes but I am not
I don't totally understand how all this works, but I'm getting this error: Fatal
OK have just started getting this error and I'm not sure why. I have
I'm not sure if I'm missing something really obvious, but I keep getting a
I am not sure why but jQuery find function is not able to find
I'm not totally sure but this looks wrong: I have a header file named
I am not sure where i've seen this before, but im sure that there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.