Welcome Guest, Not a member yet? Register   Sign In
Simple question : can't define query result without foreach ?! And I thought I wasn't a noob anymore ....
#1

[eluser]Dagobert Renouf[/eluser]
Hello everyone.

I'm facing a problem I'm sure will find a quick and efficient answer, as I'm stucked right here !

When you want to display mysql query results, you do this :

Code:
foreach($query->result() as $row)
{
     echo $row->id;
}

And this works fine.

However I'm having a ONE RESULT ONLY query running, and I want to do this to simplify things:

Code:
$row = $query->result();
echo $row->id;

Why does it return an error ?
Code:
Message: Trying to get property of non-object


Messages In This Thread
Simple question : can't define query result without foreach ?! And I thought I wasn't a noob anymore .... - by El Forum - 06-25-2008, 06:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB