Error updating table in database through PHP
<p>I have this pre-made function</p>

<pre><code>public function updateAlbum() 
    {
      global $database;

        $attributes = $this-&gt;sanitized_attributes();
        $attribute_pairs = array();
        foreach($attributes as $key =&gt; $value) 
        {
          $attribute_pairs[] = "{$key}='{$value}'";
        }
        $sql = "UPDATE ".self::$table_name." SET ";
        $sql .= join(", ", $attribute_pairs);
        $sql .= " WHERE album_id=". $database-&gt;escape_value($this-&gt;album_id);

        $database-&gt;query($sql);
      return ($database-&gt;affected_rows() == 1) ? true : false;
    }
</code></pre>

<p>As the title of this post says, I would like to update an information on a certain table. Now, for me to be able to do that, I came up with these lines of codes:</p>

<pre><code>$album_id = $_GET['album_id'];
if(isset($album_id))
        {   
            $album = new Album();
            $album-&gt;album_id = $album_id;
            $album-&gt;album_name = $_POST['album_name'];
            $album-&gt;date_created = date('Y-m-d H:i:s');     
            $album-&gt;updateAlbum();      
        }
</code></pre>

<p>What happens here though is that a new record gets created. Basically, I really just wanted to be able to update the <code>$album-&gt;album_name</code> so I tried doing this:    </p>

<pre><code>$album_id = $_GET['album_id'];
    if(isset($album_id))
    {   

        $album-&gt;album_name = $_POST['album_name'];

        $album-&gt;updateAlbum();

    } 
</code></pre>

<p>But I get an error like this: Call to undefined method stdClass::updateAlbum() 
Help please?   </p>
