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

    Join Date
    Oct 2000
    Posts
    15
    Rep Power
    0
    $query = "select id from
    poll where internaltitle = '$playername'";
    $result = mysql_query($query,$connection) or die("2 Error in query,");

    $new_id = mysql_fetch_result($result); <-- I know it is wrong, but you get the idea.

    I need to have $new_id assigned to the result of the query. All the query is doing is pulling a two digit number.
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,640
    Rep Power
    4476
    Read the manual and use this:

    $new_id = mysql_result($result,0);

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    61
    Rep Power
    14
    I usually use mysql_fetch_row() for that, though I use a bunch of other stuff as well, that's my main one.
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,640
    Rep Power
    4476
    You can use either. If your just getting one variable returned from a result, it's quicker to use mysql_result().

    Personal preference, though.

    ---John Holmes...

Similar Threads

  1. need ideas on listing query results
    By loco30 in forum PHP Development
    Replies: 1
    Last Post: February 14th, 2004, 01:17 AM
  2. Can anyone help with mysql query and results?
    By msmith29063 in forum MySQL Help
    Replies: 3
    Last Post: February 8th, 2004, 03:43 AM
  3. two query results as one?
    By Tommieboy in forum PHP Development
    Replies: 2
    Last Post: February 3rd, 2004, 12:40 PM
  4. Replies: 3
    Last Post: January 26th, 2004, 03:38 PM
  5. Overwriting mysql query with the query results
    By onerandomday in forum PHP Development
    Replies: 1
    Last Post: January 14th, 2004, 04:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo