开发者

PHP & MySQL - Deleting users problem

For some reason if a user does not have data in the info or pid MySQL tables I can't delete the user form any other table like the user table is there some way I can have the user deleted even if the user has not entered data into the other tables except the user table?

Here is part of the code for deleting members.

    if(($months >= 3) && ($row['deletion'] == 1)){


        $dqc = mysqli_query($mysqli,"DELETE FROM info WHERE user_id = '" . $row['user_id'] . "'");
        if(!$dqc){ print mysqli_error($mysqli); }

        $dpq = mysqli_query($mysqli,"DELETE FROM pid WHERE user_id = '" 开发者_Go百科. $row['user_id'] . "'");
        if(!$dpq){ print mysqli_error($mysqli); }

        $duq = mysqli_query($mysqli,"DELETE FROM users WHERE user_id = '" . $row['user_id'] . "'");
        if(!$duq){ print mysqli_error($mysqli); }
    }


Sounds like you may have some dependency issues regarding foreign key constraints. What are the relationships like between the user, info and pid tables? Depending on the relationships you may want to re-order your delete statements.


Make sure this is populating properly

 $row['user_id']
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜