FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Multidimensional Arrays
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Multidimensional Arrays [message #180414 is a reply to message #180409] Mon, 11 February 2013 22:29 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/11/2013 3:00 PM, Rita Ferreira wrote:
> Hi,
> I need some help with multidimensional arrays, if possible.
>
> I have 3 classes, one to acces to DB called config, another called NoticiasController and another called Noticias and the index.php.
>
> On index, I'm creating an object of NoticiasController and calling the method listar().
> On NoticiasController I have an object of config and there on config I query the DB like this:
>
> SELECT id, noticia FROM NOTICIAS;
>
> On the config I only have a mysql_query command.
>
> Then on NoticiasController I'm trying to manage the data returned by that query, and here's problem :S
>
> I'm doing something like this:
>
> NoticiasController.php
>
> public function listar()
> {
>
> require_once "../config.php";
> require_once'/Models/Noticia.php';
>
> $a=new config();
> $sql="SELECT id_noticia, corpo_noticia FROM Noticias";
> $res=$a->listar($sql);
>
> $e=array();
>
> while ($row = mysql_fetch_assoc($res))
> {
> $temp=new Noticia($row["id_noticia"],$row["corpo_noticia"]);
> $e[]=$temp; <------------ here is the problem
> ?> <br /> <?php
> }
>
>
> return $e;
> }
>
> Noticia.php
> (…)
> public function __construct($Id_Noticia, $Corpo_Noticia)
> {
> $this->Id_Noticia = $Id_Noticia;
> $this->Corpo_Noticia = $Corpo_Noticia;
> }
>
>
> public function getCorpoNoticia(){
> return $this->Id_Noticia;
> }
> (…)
>
>
> My goal is to insert on $e every object of Noticia for then send it to index and print the values but when I try to do it I got the error "Fatal error: Call to a member function getCorpoNoticia() on a non-object in /NoticiaController ".
>
> Can you help me? I'm having lots of problems working with arrays and I've tried another ways to do this but I have never reach what I want.
>
> Thanks :)
>

What's your actual code and where are you getting the error? The error
you indicated will not occur on the like you pointed out.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: P = NP in Binary Portrait
Next Topic: Connection with Sql server on Windows
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 06:24:27 GMT 2024

Total time taken to generate the page: 0.03988 seconds