im kinda stuck again, could some one please tell me why this dosent work
mysql_query("DELETE FROM messages WHERE from='$fromid', sento='$myid'");
it is to delete more than one message
im kinda stuck again, could some one please tell me why this dosent work
mysql_query("DELETE FROM messages WHERE from='$fromid', sento='$myid'");
it is to delete more than one message
could some one please tell me why this dosent work
Because the syntax is incorrect.
It should be...
mysql_query("DELETE messages WHERE `from` = '$fromid' AND sendto = '$myid'");
PS: Using the word from as a field name in your database is a pretty bad idea. It is a reserved word (hence the backticks).
thanks for the fast reaply but it didnt work , i put in
mysql_query("DELETE messages WHERE from='$fromid' AND sendto='$myid'");
That is NOT what I posted.
no i know the only diffrence is you put `` around form, but i thought it was a mistake because you didnt put it around sendto, just tried
mysql_query("DELETE messages WHERE from
= '$fromid' AND sentto
= '$myid'");
didnt work either
The backticks ` are there because from is a reserved word in sql. You really should avoid using them.
Anyway... lets try some debugging. What does this produce?
mysql_query("DELETE messages WHERE `from` = '$fromid' AND `sentto` = '$myid'") or die(mysql_error());
so do you think it would work fine it i just change the field name to sentfrom?, this gave me the 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 from
= '5' AND sentto
= '7'' at line 1
Sorry... What was I thinking? I think your from was throwing me off. Try...
mysql_query("DELETE FROM messages WHERE `from` = $fromid AND `sentto` = $myid") or die(mysql_error());
Also note you dont need to surround your values in quotes if they are numeric.
ahh excellent thanks very much for your help, its working now