Re: is the array from mysql_fetch_array really an array (or does it just pretend ) ???? Creating an array with mysql table fieldnames in it....
| From: | Nick | Date: | Tue, 25 Jul 2000 13:11:37 +0000 |
| Subject: | Re: is the array from mysql_fetch_array really an array (or does it just pretend ) ???? Creating an array with mysql table fieldnames in it.... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8027@lists.php.net to get a copy of this message | ||
aaaaaaaahhhhhhhhhhhhhh now that would explain it....... :- )
pardon my ignorance, as i often find myself repeating these days i've only
been programming for a month now....
two questions then:
* what is the difference between an object and an array ?
* how do i get to make an array with the fieldnames inside it using the
object returned by mysql_fetch_array ? (and also, why does my code not work
for $fields[]= $fieldname[name] if it does for echo "$fieldname[name]" ?)
thanks so much for all of your help ;p
nick
----- Original Message -----
From: gautam <gautamw@mahindrabt.com>
To: Nick <nick@carrierworld.com>
Sent: Tuesday, July 25, 2000 1:45 PM
Subject: Re: [PHP] is the array from mysql_fetch_array really an array (or
does it just pretend ) ???? Creating an array with mysql table fieldnames in
it....
> hi Nick,
> you're using mysql_fetch_field() which doesnt return an array.It returns
an
> object.Is that the reason?
> regards
> gautam.
>
> Nick wrote:
>
> > Hi,
> >
> > I have been trying to solve this one for a while now, but i still =
> > haven't gotten over the problem though i really need to. I am trying to
=
> > create an array with all the names of the fields of a mysql table in it.
=
> > I use the following code:
> >
> > while ($fieldnames=3D$check->fetch_fields())
> > {
> > echo "this is a fieldname: $fieldnames[name]";
> > $fields[]=3D $fieldnames[name];
> > }
> >
> > fetch_fields is a function in a class which goes as follows:
> >
> > function fetch_fields()=20
> > {
> > return mysql_fetch_field($this->Query_ID);
> > }
> >
> > nothing fancy. However, this code returns the following:
> >
> > this is a fieldname: ID
> > Warning: Variable $fieldnames is not an array or string in =
> > /htdocs/functions.inc.php on line 37
> >
> > this is a fieldname: name
> > Warning: Variable $fieldnames is not an array or string in =
> > /htdocs/functions.inc.php on line 37
> >
> > this is a fieldname: email
> > Warning: Variable $fieldnames is not an array or string in =
> > /htdocs/functions.inc.php on line 37
> >
> > this is a fieldname: photo
> > Warning: Variable $fieldnames is not an array or string in =
> > /htdocs/functions.inc.php on line 37
> >
> > this is a fieldname: added
> > Warning: Variable $fieldnames is not an array or string in =
> > /htdocs/functions.inc.php on line 37
> >
> > The fact that it manages to deal with the echo properly but not with the
=
> > assigning of fieldnames[name] to a new array really gets me.... What on
=
> > earth am I doing wrong ???????????????
> >
> > nick
>
> --
> If it is to be, it is up to me
>
>
>