sam06 Posted January 21, 2009 Share Posted January 21, 2009 Hi there- Any ideas how to remove the error? It's a query to check if the records in there. It all seems to work for me, apart from throwing up that error. Ideally I just want to stop it showing it, as it all works fine. $check = mysql_query("SELECT uniqueid FROM tomhar WHERE ip='$ip' "); if($check) { $result = mysql_result ($check, 0, 'uniqueid'); } Originally there was no IF, but I put that in to try and stop the error from coming up. Unfortunetly it didn't. The error code is saying line 19, which is the $result= line. Cheers, Sam Quote Link to comment Share on other sites More sharing options...
jjacquay712 Posted January 21, 2009 Share Posted January 21, 2009 $check = mysql_num_rows(mysql_query("SELECT uniqueid FROM tomhar WHERE ip='$ip' ")); if( $check > 0 ) { //do whatever } Quote Link to comment Share on other sites More sharing options...
flyhoney Posted January 21, 2009 Share Posted January 21, 2009 $query = "SELECT uniqueid FROM tomhar WHERE ip='$ip'"; $result = mysql_query($query); if (mysql_num_rows($result) == 1) { $result = mysql_result($result, 0, 'uniqueid'); } Quote Link to comment Share on other sites More sharing options...
sam06 Posted January 21, 2009 Author Share Posted January 21, 2009 Thanks very much both of you In the end I went for $check = mysql_num_rows(mysql_query("SELECT uniqueid FROM tomhar WHERE ip='$ip' ")); if( $check > 0 ) { $check5 = mysql_query("SELECT uniqueid FROM tomhar WHERE ip='$ip' "); $result = mysql_result ($check5, 0, 'uniqueid'); } Quote Link to comment Share on other sites More sharing options...
flyhoney Posted January 21, 2009 Share Posted January 21, 2009 That definitely works but I would say it's silly to run the query twice! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted January 21, 2009 Share Posted January 21, 2009 @sam06: Use flyhoney's method. In the one you have now, you're doing the query twice. That wastes resources and it absolutely pointless. EDIT: Also, mysql_result() is pretty slow compared to the other fetching functions. Use one of those as opposed to mysql_result(). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.