Nested class in php 5
<p>I want to use a class inside other class.</p>

<p>This is my first class:</p>

<pre><code>class mydb {
  public function connect($host="localhost",$user,$pass,$data,$persistency=False) {
    $this-&gt;host = $host;
    $this-&gt;user = $user;
    $this-&gt;pass = $pass;
    $this-&gt;data = $data;
    $this-&gt;persistency = $persistency;

    $this-&gt;link=@mysql_connect($this-&gt;host,$this-&gt;user,$this-&gt;pass)or die(mysql_error());

    If(($this-&gt;link) AND ($this-&gt;data)) {
      If(@mysql_select_db($this-&gt;data,$this-&gt;link) or die(mysql_error())) {
        return True;
      }
    }
    return False;
  }

  public function query($query="",$sup="") {
    If($sup) {
      $query=@mysql_query($query,$this-&gt;link)or die("&lt;br /&gt;&lt;br /&gt;".mysql_error()."&lt;br /&gt;&lt;br /&gt;");
    } Else {
      $query=@mysql_query($query,$this-&gt;link) or die("&lt;br /&gt;&lt;br /&gt;".mysql_error()."&lt;br /&gt;&lt;br /&gt;");
    }
    return($query);
  }
}
</code></pre>

<p>This is my second class:</p>

<pre><code>class articles {
  function getpath($id) {
    $sql=$db-&gt;query("select id,name from articles where id='$id'");
    $row=mysql_fetch_array($sql);

    return $row['name'];
  }
}
</code></pre>

<p>I receive this error: <code>( Fatal error: Call to a member function query()  )</code></p>
