View Full Version : How to exclude some data from mysql_result()

12-28-2006, 07:25 AM
This is part of a script I'm writing:

$query2 = "SELECT * FROM added WHERE NeedToAdd='$ip2'";
$result2 = mysql_query($query2);
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
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)

12-28-2006, 08:20 AM
How about the @-operator (http://www.php.net/manual/en/language.operators.errorcontrol.php)?

$result2 = @mysql_query($query2);

12-28-2006, 09:46 AM
Check whether mysql_num_rows returns a number greater 0 before you use mysql_result.