Merge Image save to mysql database without clicking anything

Can anyone help me about my problem?
I have successfully merge a image but i dont know how to insert it into DB

the code is something like this
      $logo = "SecurityBank.png";
      $white_image = "image_size.png";
      $targetfile = "Phobo_New_Image.png";

      $Whitebackground = imagecreatefrompng($white_image);
      $whitebgW = imagesx($Whitebackground)-300;
      $whitebgH = imagesy($Whitebackground);
      $partnerlogo = imagecreatefrompng($logo);
      $partnerlogoW = imagesx($partnerlogo);
      $partnerlogoH = imagesy($partnerlogo);
      $photoFrame = imagecreatetruecolor($whitebgW,$whitebgH);
        $destlogo_x = $whitebgW - $partnerlogoW;
      $destlogo_y = $whitebgH - $partnerlogoH;
      imagecopyresampled($photoFrame, $Whitebackground, 0, 0, 0, 0, $whitebgW, $whitebgH,$whitebgW, $whitebgH);
      imagecopy($photoFrame, $partnerlogo, $destlogo_x-300, $destlogo_y-400, 0, 0, $partnerlogoW, $partnerlogoH);
      imagepng($photoFrame, $targetfile);
<center><img src="<?php echo $targetfile ?>" width="700px" name="target" id="target" height="400px"></center>'

name="target" id="target"

I want to insert it into datbase my setTimeout or anything that the file $target is save into to the database as blob or longtext.
Mico BeldadAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Generally speaking, we do not put images into a database.  Instead, we store the image file (output from imagePNG() function) in the file server and put the URL of the image file into the database.  The reasons for this are many, but the most important reasons are performance and backup.  BLOB fields are often bad for both.  

But if you want to store the image file in the database, you can do that easily.  As soon as you write the $targetfile, you can read it back into a PHP variable with file_get_contents().  Then, escape the variable and INSERT it into the database table.

Information on the right ways to use MySQL is available in this article:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eddie ShipmanAll-around developerCommented:
While I tend to agree with Ray that you shouldn't store images in a DB, if you really need to, I would convert them to using base64_encode() and them storing them in a Text column. Then to use them, you would have to base64_decode() them.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.