Jump to content

Another header problem!


a1amattyj

Recommended Posts

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.

Link to comment
Share on other sites

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());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.