Database not updating row

Before you assume I didn’t establish a database connection, I did. the only portion of the code that does not update is the if empty statements.

All the values can be echoed out correctly, it’s just that query doesn’t work.

This is in directory config and named stuff.php

 $user = $mysqli->real_escape_string($_SESSION['username']);
 $user_query = "SELECT * FROM users WHERE username = '$user'";
 $result = $mysqli->query($user_query);
 $row = $result->fetch_assoc();
 $referrer = $row['ref'];
 $refearn = $row['refearn'];

verify.php

include('config/stuff.php');
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {  // Get Real IP              
    $IP = $_SERVER['HTTP_X_FORWARDED_FOR']; 
} else { 
    $IP = $_SERVER['REMOTE_ADDR'];
}

if ($IP=="external server ip here") {
        if (!empty($referrer)){
            $mysqli->query("UPDATE users SET points=points+10, refearn = refearn+10 WHERE username='".$referrer."'") or die(mysqli_error($mysqli)); 
        }
        $mysqli->query("UPDATE users SET points=points+".$earnings.", completed = completed+1 WHERE username='".$subid."'") or die(mysqli_error($mysqli));
}       

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories