Delete table record with foreign key

Asked

Viewed 740 times

-2

Where is the Error?

DELETE FROM postagens WHERE id='$p_id' AND u_id='$u_id' SET FOREIGN_KEY_CHECKS = 0;

Clarifications:

p_id = id of posts(primary key)

u_id = user id(foreign key)

  • 1

    What error message reported by PHP and/or Mysql?

  • No error, however is returning -1 affected lines! $Comm = "SET FOREIGN_KEY_CHECKS = 0; DELETE * FROM posts WHERE id='$p_id' AND u_id='$u_id'; SET FOREIGN_KEY_CHECKS = 1;";

  • Place this inside a Try catch and edit your reply by placing the error message that occurs

1 answer

-1

I believe you must first execute the SET FOREIGN_KEY_CHECKS=0; and then the DELETE FROM ...;. Both with their respective ; since they are separate commands.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.