I'm using the following chunk of code to see if a user is activated and activate them if not etc. The mysql_affected_rows() is giving me problems. It is always 0 for some reason. The db values are updating, and if I run the same query (with valid username) in phpmyadmin then I get a results of 1.
$data = $_GET['username'];
$query = "UPDATE users SET activated='1' WHERE username='$data'";
mysql_query($query);
$result = @mysql_query ($query);
//doesn't work affected_rows is always 0??
if (mysql_affected_rows() == 0) {
$q = "SELECT id FROM users WHERE username='$data' AND activated='1'";
if (mysql_num_rows(mysql_query($q))==0){
echo '<h1>Error!</h1><p>There has been an error processing your activation. Please re-try and if the problem persists then contact the administration.</p>';
}else{
echo '<h1>Error!</h1><p>Your username is already activated. Please go to the <a href="login.php">Login Page</a> to begin creating your profile.</p>';
}
}else{
echo '<h1>Thank you!</h1><p>You are now registered. Please head over to the <a href="login.php">Login Page</a> to begin creating your profile.</p>';
}
Thanks for the help