Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to exclude some data from mysql_result()

    This is part of a script I'm writing:
    PHP Code:
    $query2 "SELECT * FROM added WHERE NeedToAdd='$ip2'";
    $result2 mysql_query($query2);
    $ips=mysql_result($result2,0,"AddedTheirCode"); 
    I'm running a while statement on all the data that is being displayed, and those three lines are run on each one.

    If the certain data's "$ip2" is not in the "added" table in the "NeedToAdd" column, I get a
    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 8
    error.
    Is there any way I can exclude data whose "$ip2" is not in the "added" table in the "NeedToAdd" column? Or just someway to stop that error from showing? (I can't edit any config files)

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    How about the @-operator?
    Code:
    $result2 = @mysql_query($query2);

  • #3
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Check whether mysql_num_rows returns a number greater 0 before you use mysql_result.

    dumpfi
    "Failure is not an option. It comes bundled with the software."
    ....../)/)..(\__/).(\(\................../)_/)......
    .....(-.-).(='.'=).(-.-)................(o.O)...../<)
    ....(.).(.)("}_("}(.)(.)...............(.)_(.))Ż/.
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
    Little did the bunnies suspect that one of them was a psychotic mass murderer with a 6 ft. axe.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •