Hello, help please, there is a table of messages_group it looks like this:

 user_one int(11) NOT NULL, user_two int(11) NOT NULL hash int(11) NOT NULL 

There is a button to delete

 <a href='?act=delete2&ps_id=<?=$hash?>'> <img src="background/trash.png" class="hrefff"></a> 

And the delete function itself

 <?php if ($act == 'delete2') { mysql_query("DELETE FROM `message_group` WHERE `hash`='$hash' LIMIT 1"); } ?> 

That is why the record is not deleted, what is the error? please correct.

  • $ act is what? Superglobalka? If yes, then it is better to turn off, 2014 is still outside )) - MDJHD
  • and delete2 is better to replace something supposed to be, then you will not figure it out yourself - etki

2 answers 2

try this

 if ($_GET['act'] == 'delete2') { mysql_query("DELETE FROM `message_group` WHERE `hash`='".$hash."'"); } 
  • Thank you so much. - andreykartavtsev

Maybe it is better to transfer the hash by the POST method, or is it guaranteed not to contain any invalid characters in the URL? Check what contains $ hash after passing through the URL, for example, by adding to the IF statement:

 echo $hash;