Start by checking what the result is of your query() calls, and if they're false, generate some debug output, either to a log file or direct to the screen while in development mode, e.g.:
if(mysqli_query($db,$AddQuery) == false) {
die("<pre>DB ERROR:\n".print_r(mysqli_error($db), 1)."\n".htmlentities($AddQuery)."</pre>");
}
If the query fails, then you take that debug output and start working back from there to figure out what went wrong.
PS: That's just a quick and dirty approach. Better would be throwing an exception, with an exception handler that would be smart enough to log info to the error log and display something more "friendly" (and less overly informative) to the user.