PDA

View Full Version : PHP not updating mysql



revin
November 26th, 2008, 03:45 PM
################################################## ##############################
#------------------------------------------------------------------------------#
# Activate Function
#------------------------------------------------------------------------------#
################################################## ##############################
function Activate(){
DBconn();
$result = mysql_query("SELECT userid FROM users WHERE code=".$_GET["code"]);
$row=mysql_fetch_row($result);
$ID=$row['userid'];
if(mysql_numrows($result) != 0){
$query = mysql_query("UPDATE users SET isactive='1',code='0' WHERE userid='$ID'");
echo 'Your account is now active, feel free to login now'.$row['userid'];
}else{
echo _VALIDATE_ERROR;
}

}

i'm not sure what i'm doing wrong, its supposed to check and see if theres a matching code in the database and update it if it does find a matching code

but so far does not can someone help please?

borrob
November 27th, 2008, 03:37 AM
if code is a varchar or char:

mysql_query("SELECT userid FROM users WHERE code=".$_GET["code"]);

should be:

mysql_query("SELECT userid FROM users WHERE code='".$_GET["code"] . "'");