Trouble uploading/retrieving image to/from MySql database in android
<p>I am trying to upload an image to my MySql database from my android application using JSON and PHP.  For whatever reason, the image is not being inserted/updated in the database.  Here is my code.</p>

<p>Android Code:</p>

<pre><code>    Bitmap photo = extras.getParcelable("data");
    ByteArrayOutputStream stream = new (ByteArrayOutputStream();
    photo.compress(Bitmap.CompressFormat.JPEG, 100, stream);
    byte [] b = stream.toByteArray();
    user.Picture = Base64.encodeToString(b, Base64.DEFAULT);
    UploadPicture(user.Picture, user.Email);


    public static void UploadPicture(String photo, String email)
    {
        final String conn = GC.UpdateUserPicture;
        ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
        nameValuePairs.add(new BasicNameValuePair("email", email));
        nameValuePairs.add(new BasicaNameValuePair("photo", photo));
        try {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(conn);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        }
        catch(Exception e) {}
    }
</code></pre>

<p>PHP Code:</p>

<pre><code>    &lt;?php
//Create variables to get the appropriate parameters.
$photo = $POST['photo'];
$email = $_POST['email'];
$finalPicture = base64_decode($photo);

//DB Connection Credentials
$dsn = host/dbname;
$dbUsername = username;
$dbPassword = password;
$result = array();

try
{
    $pdo = new PDO($dsn, $dbUsername, $dbPassword);

    $query = $pdo-&gt;prepare("UPDATE User SET Picture = :pict WHERE Username = 
             :em");
    $query-&gt;execute(array("pict" =&gt; $finalPicture, "em" =&gt; $email));
}
catch(PDOException $e)
{
    die("Could not connect to database\n");
}
    ?&gt;
</code></pre>

<p>Any help would be greatly appreciated!</p>
