#1
  1. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    49
    Rep Power
    15
    Hi,

    I know i made a post quite similar to this a few days ago, 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=$check->fetch_fields())
    {
    echo "this is a fieldname: $fieldnames[name]";
    $fields[]= $fieldnames[name];
    }


    fetch_fields is a function in a class which goes as follows:

    function fetch_fields()
    {
    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


    What am I doing wrong ???????????????


    nick
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    43
    Rep Power
    15
    Try this and see what happens:

    echo "this is a fieldname: ".$fieldnames["name"]."<br>n";
    $fields[]= $fieldnames["name"];




    [This message has been edited by lhallusa (edited July 26, 2000).]

Similar Threads

  1. Replies: 1
    Last Post: January 27th, 2004, 08:23 PM
  2. Replies: 2
    Last Post: November 19th, 2003, 10:06 PM
  3. Replies: 3
    Last Post: November 19th, 2003, 12:52 PM
  4. Trouble with multidimensional array values
    By LCLpuddle in forum C Programming
    Replies: 5
    Last Post: November 16th, 2003, 03:49 PM
  5. multi dimensional arrays - Can't grasp how to?
    By Kaleina in forum PHP Development
    Replies: 17
    Last Post: November 5th, 2003, 04:18 PM

IMN logo majestic logo threadwatch logo seochat tools logo