Reputation: 203
I have applied a insert query but its giving error .
$registerquery = mysql_query("INSERT INTO `registration`(`Activation`) VALUES('".$activation."') WHERE email= '". trim($_POST['email']) ."'");
Upvotes: 1
Views: 92
Reputation: 37233
if you want just update a column in table so you need an UPDATE
not INSERT
.
and also you should sanitize you POST variable to prevent sql injection.
$email = mysql_real_escape_string($_POST['email'])) ;
$registerquery = mysql_query("UPDATE `registration`
SET `Activation` '".$activation."'
WHERE email= '". trim($email) ."'");
Upvotes: 2
Reputation: 3329
Use update statement instead of INSERT to use where clause
$registerquery = mysql_query("UPDATE `registration`
SET `Activation` = '".$activation."
WHERE email= '". trim($_POST['email']) ."'"
);
Upvotes: 1
Reputation: 1027
It seems you are trying to overwrite an existing value use an UPDATE statement and not an INSERT statement this is the reason why it is not working. INSERT works when you are trying to insert a new value there should not be a condition in it (where clause).
Upvotes: 2
Reputation: 391
check this registration
(Activation
) it does not seem correct, the ` should maybe be ' and maybe you should start the query with @ in order to avoid sql injection attack
Upvotes: 1