Category Archive for: Binary Objects and Image Loading

So Which Approach Is Best

Here you are, with two totally different approaches to getting users’ images into your database (or at least the paths to those images). In fact, you’ve probably spent as much time working through this code as any other code you’ve run across in your PHP journey. Now, one question begs to be answered: which approach is best? The…

Read More →

Embedding an Image Is Just Viewing an Image

Finally, it’s back to <;how_user.php. Remember, show_Image.php was actually a bit of a diversion. It’s a necessary one, but the point isn’t a script that displays an image. Instead, it’s a script that displays a user, and that just happens to mean you have to show that user’s image. But, you have all the work done now to…

Read More →

Show Me the Image!

At this point, you have all your data, and you can even get the image for a particular user. All that’s left is to actually show the image, right? Yes, but you have an entirely different situation than when you had the image on a file system and just needed to point at that file. In this…

Read More →

Connecting Users and Images

At this point. you have two tables-users and Images-but no connection between them. That’s your next challenge. When you load a user from the users table and display his profile by using user.php, how do you determine which image in the images table you should display? Clearly, you need some linkage between those two tables. You already have…

Read More →

Getting the Correct 10 Before Redirecting

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. This isn’t as much of a mystery as it first seems. Here’s the last bit of your code from create_user.php What’s…

Read More →

Your Binary Data Isn’t Safe to Insert…Yet

The code you built in the previous section looks good, but if you run this code, you’re likely to see some errors. First, that binary data has all sorts of weird characters on which PHP and MySOL are going to choke. There’s always the possibility of running into characters that are a problem, but it’s especially true when…

Read More →

Inserting a Raw Image into a Table

It’s time to revisit create_users.php. You’re going to use a lot of your existing code, but there are also some changes to make. All of the checks you’ve put in place to ensure that your user uploaded a valid image, that no errors were generated by the server or PHP, and that the file is an image via…

Read More →

Storing Different Objects in Different Tables

Up until now, you’ve been working with one table: users. That’s because you’ve been working with a single entity: a representation of one of your users. Everything in that table-the first and last name, the email address, and the Facebook URL and Twitter handle-are parts of that user. Put another way, everything in the users table describes a user. But,…

Read More →

Binary Objects and Image Loading

At this point. you have images on a file system, and the paths to those images .stored in a database. In your PHP scripts, you convert that file system path to a web path, and then display the image. This works, and it works pretty well. In fact. you could run with that solution and likely never have…

Read More →

Back to Top