You are doing it the wrong way. Don't save images in database as it is not a good practice. Just save the uploaded image in a directory and save the path to that image in database. It would save you some database space and search time.
Here is some sample code
Refer to http://www.w3schools.com/php/php_file_upload.asp for help