Re: Returning results

From: Date: Thu, 21 Oct 2010 00:49:21 +0000
Subject: Re: Returning results
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-308902@lists.php.net to get a copy of this message
On Wed, 2010-10-20 at 20:11 -0400, Bastien wrote: > > On 2010-10-20, at 7:59 PM, David McGlone <david@dmcentral.net> 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.

« previous php.general (#308902) next »