a1amattyj Posted June 14, 2008 Share Posted June 14, 2008 Hello, This little code, checks for the ip in the mysql database, if its wrong, goes to login, if right, just update with the current ip. function UpdateIp($username){ require("../multi_operations/config_inc.php"); $ip = getenv("REMOTE_ADDR"); $query = "SELECT FROM multi_admins WHERE username = '$username'"; $result = mysql_query($query); if($row = mysql_fetch_array($result)){ if($row['ip'] == $ip){ //Do nothing }else{ session_destroy(); header("location:login.php"); } $query = "UPDATE multi_admins SET ip = '$ip' WHERE username = '$username'"; $result = mysql_query($query); }else{ session_destroy(); header("location:login.php"); } } php error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/./public_html/multi_operations/admin_functions.php on line 154 Warning: Cannot modify header information - headers already sent by (output started at /home/./public_html/multi_operations/admin_functions.php:154) in /home/./public_html/multi_operations/admin_functions.php on line 168 Any ideas? If i see this message, and try to click any other action, my session check logs them out ^. Can i do a javascript redirect instead of the header location? Or is that not safe.. seeming you can disable it? Thanks. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted June 14, 2008 Share Posted June 14, 2008 Fix your first error and the last one will go away. As for why you get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/./public_html/multi_operations/admin_functions.php on line 154 You most probably have an error in your SQL Query. Change $result = mysql_query($query); to $result = mysql_query($query) or die('MySQL Error: ' . mysql_error()); Quote Link to comment Share on other sites More sharing options...
tapos Posted June 14, 2008 Share Posted June 14, 2008 try to debug like bellow $result = mysql_query($query) or die('SQL error'); i think this is database connection problem that why $result variable doesn't contain any resource identifier, mysql_query() return a false 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.