...

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



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

$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)

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


$result2 = @mysql_query($query2);

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

dumpfi



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum