I'm making a private messages application and I am trying to create a 'deleted messages' folder so the messages that the user wants to delete from their inbox or sent folder go to 'deleted'. I managed to write the code to delete them completely however that is not what i want. I created another table in my database, named 'deleted' so I'm trying to delete them from the inbox and then insert them there.
This is what I have until now:
if ( isset($_GET['delete'])) {
$multiple = $_GET['multiple'];
$i=0;
$q = "insert into deleted (select * from email where to_user = '$user')";
foreach($multiple as $msg_id)
{
$i++;
if ($i==1) {
$q .= " WHERE id = ". mysql_real_escape_string($msg_id)."";
} else {
$q .= "OR id = ". mysql_real_escape_string($msg_id)."";
}
}
mysql_query($q) or die (mysql_error());
header("location: " .$_SERVER['PHP_SELF']);
exit();
}
It is giving me this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 14' at line 1
is_deleted? With a1(yes) or0(no)SELECT.