This php code updates a database entry. The form consists of a checkbox (name = download) and a hidden field so I can check it has actually been sumbitted(name = updated). When I run this code it gives me the success message but the database remains unchanged. Why is this?
if(isset($_POST['updated'])){
$candownload = isset($_POST['download']) ? "y":"n";
$query = sprintf("UPDATE `images` SET `download`='%s' WHERE `url`='%s'",
mysql_real_escape_string($candownload),
mysql_real_escape_string($url));
mysql_select_db($dbname,$con);
mysql_query($query) or die(mysql_error());
$message = "<div class='alert alert-success'>Your settings have been updated</div>";
$_SESSION['message'] = $message;
header('Location: account');
}else{
$message = "";
}
Thanks for any help