hi every one. i have two tables

table_1
(
    std_id primary key,
    std_name,
    tchr_id foreign key
);

table_2
(
    tchr_id primary key,
    tchr_name
);

as from the above tables i have the foreign key constraint. it mean if i want to delte teacher id it must be firstly deleted from the table 1 and so on so forth.
but now my question is m trying to delete with the following query in php

    $query = mysql_query("DELETE FROM table_2 WHERE tchr_id='".$id."'") or die(mysql_error());

but this could't delted and an error is shown as it could be for the foreign key constraint. but i want to show the error in such a way that name of the tables couldn't be shown...

but i want to show the error in such a way that name of the tables couldn't be shown...

Is that all?

$query = mysql_query("DELETE FROM table_2 WHERE tchr_id='".$id."'") or die("Oops, we have a problem, please contact the administrator.");

Change message to suit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.