How in this code I can generate a message if a a register is associate with a category that I canīt delete?? In this case appears the message "Category deleted" if there is association or not.


PHP Code:
if ($_POST["del_cat"] == "Apagar")
    {
                
$sql "delete from cat_links where cat_ID = ".$_POST["cat_ID"]." and cat_ID not in (select cat_ID from links) and cat_ID not in (select cat_ID from subcat_links)";
                
$query query($sql);
                if (
$query == 1)
                {
                    echo 
"<script>alert('Category deleted.');</script>";
                }
                else
                {
                    echo 
"<script>alert('Error deleting.');</script>";
                }
    }