0

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...

Edited by shahai.ali: gramatical error

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by adam.adamski.96155
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.