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

    Join Date
    Jun 2000
    Posts
    49
    Rep Power
    15
    hi,

    i'm trying to do the following loop:

    while ($fields = $db->fetch_fields())
    {
    $fields = $db->fetch_fields(); //this function returns mysql_fetch_field

    echo "$fields[name]n";
    $fieldname[$i] = $fields['name'];
    $i++;
    }


    however when i do this i get the message

    Warning: Variable $fields is not an array or string in /scipt.php on line 103


    the "echo" function is there for debug purposes, and works in printing out the correct fieldname..... Please let me know what i'm ding wrong !!!!

    cheers,
    nick


    [This message has been edited by zcrar70 (edited July 21, 2000).]
  2. #2
  3. No Profile Picture
    a total freak
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    33
    Rep Power
    15
    Just wondering, which variable $fields is the error code reffering at?
    Is that fetch_fields() function really empty between it's brackets..? maybe those could also be the problem,..?

    ------------------
    ---freakyG!---
    kinumedia, web developer
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    [QUOTE]Originally posted by zcrar70:
    [B]hi,

    i'm trying to do the following loop:

    while ($fields = $db->fetch_fields())
    {
    $fields = $db->fetch_fields(); //this function returns mysql_fetch_field

    echo "$fields[name]n";
    $fieldname[$i] = $fields['name'];
    $i++;
    }

    Well, for one thing, you don't need to assign the fetch_fields to $fields twice. When you call
    while ($fields - $db->fetch_fields())
    if already assigns the fields to $fields, so why are calling it again on the next line? That may be causing your problem, not sure. Fix that and see if your problem goes away.

    ---John Holmes...
  6. #4
  7. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    49
    Rep Power
    15
    tried that but unfortunately it doesn't solve the problem....

    $fields is the result of mysql_fetch_fields, which according to the manual returns an array (with a key called 'name') for the next field not yet fetched by the function(if that makes any sense)

    I really can't think of a way of getting around this.....any other ideas ?

    nick

Similar Threads

  1. Flash in apache - wont work!
    By Fish_12345 in forum Apache Development
    Replies: 2
    Last Post: October 11th, 2004, 01:43 PM
  2. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 10:50 PM
  3. Experienced undergrad senior ... freelance work wanted
    By carrja99 in forum Hire A Programmer
    Replies: 0
    Last Post: January 28th, 2004, 11:32 PM
  4. I'll pay someone $150 to do some PHP work for me!
    By Noah Neiman in forum Hire A Programmer
    Replies: 16
    Last Post: January 23rd, 2004, 03:15 AM
  5. I need some specific php work done for my website
    By Noah Neiman in forum Hire A Programmer
    Replies: 1
    Last Post: January 20th, 2004, 11:31 PM

IMN logo majestic logo threadwatch logo seochat tools logo