Re: Returning results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2010-10-20 at 20:11 -0400, Bastien wrote:
> 
> On 2010-10-20, at 7:59 PM, David McGlone <david@xxxxxxxxxxxxx> wrote:
> 
> > Hi everyone, it's me again :-/
> > 
> > I'm having a whole lot of trouble figuring out how to return a result
> > from a query such as in this code example:
> > 
> > function LearnIt(){
> >  $query = "SELECT learn_id FROM mydatabase ";
> >  $result = mysql_query($query);
> >  return $result;
> >  }
> > 
> > I already achieved a connection to the database with no problem, to
> > verify I wrote this query also:
> > 
> > function GetMeARow(){
> > 
> >  $query = "SELECT learn_id FROM mydatabase ";
> >  $result = mysql_query($query);
> >  while($row = mysql_fetch_array($result)){  
> >  echo $row[learn_id];
> >  }
> > 
> > With the latter, It works as expected, echoing the 2 rows I have in the
> > DB, but I'm trying to understand the method used in the former.
> > 

> 
> 
> David, the $result variable/object is the handle to the result data set,
> not the resulting data. You would still need to access the data set via
> the Mysql_* set of functions like Mysql-fetch_array or Mysql_result like
> you did in the second example

HaHa! How burnt out does one have to be to overlook this a million times
and still not get it?

Thanks I see now :-)

-- 
Blessings
David M.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux