Is the problem that you're not sure whether the actual file specified in the code column exists, or the code column can be empty, when no picture is selected??
For the first part, use the file_exists() like Kirk said.
For the second, you can actually set a column default when you create the table to point to a default image. That way you won't have to change your code at all. If nothing is set when inserting into the database, it'll put the default value in, which is your default picture...
Hopefully that's clear...let me know if not.
---JH