Getting the Correct 10 Before Redirecting PHP Help

Unfortunately, there’s still a problem. You might have noticed something like Figure 10-2 when you got your image insertion working. You could see a blank screen, or even a totally different user, as in this scenario.

FIGURE 10-2

FIGURE 10-2

This isn’t as much of a mystery as it first seems. Here’s the last bit of your code from create_user.php

Getting the Correct 10 Before Redirecting

What’s the problem? It’s in that second-to-last line. Remember, mysql_ insert_ id returns the 10 of the last INSERT query, which is no longer the INSERT for your users table; it’s your new INSERT for images. The redirect to show_user.php is in fact working, but j,t’s sending the 10 of the image inserted rather than the user. Fortunately, you can easily fix that:

Getting the Correct 10 Before Redirecting

Try this out again, and you should be back to what you expect: a slightly broken version of show_user.php but broken in the way that you expect (see Figure 10-3),

FIGURE 10-3

FIGURE 10-3

Posted on January 12, 2016 in Binary Objects and Image Loading

Share the Story

Back to Top