Extracting all images from mysql database blob to directory
<p>i'm strugging to extract pictures from blob as it shows 
the image cannot currently be displayed because it contains errors 
when i download it
 Error interpreting JPEG image file (Unsupported marker type 0x5c)
and trying to ideintifiy which the file is and getting this via "linux shell"</p>

<blockquote>
  <p>[none]$ file PICTURE.bin
  PICTURE.bin: JPEG image data
  identify: Unsupported marker type 0x5c `PICTURE.bin' @ error/jpeg.c/JPEGErrorHandler/322 </p>
</blockquote>

<p>i tried to open it via text editor and got this weird thing at the start rather than JPEG OR JPG. it shows at the start of the image file something like this "JFIF"
i have tried a php script to extract the image and downloading it directly from phpmyadmin with no luck
the script im using is this " not mine i found it on the internet":</p>

<pre><code>&lt;?php

// ************* MODIFY THESE FOR YOUR SERVER AND DATABASE SETTINGS *************

// y = first letter in yourdomain.com
// o = second letter in yourdomain.com
$basedir = '/home/zzz/public_html/z/'; // Needs trailing slash
$host    = 'localhost';
$user    = 'zz';  //(user information)
$password= 'zz';  //(password information)
$dbname  = 'zzz';

$type            = 'jpg';
$blob_id         = 'APLT_ID';
$blob_data       = 'PICTURE';
$blob_table      = 'zzzz';

// ************************************************** ***************



$db = mysql_connect($host, $user, $password) or die("Could not connect: " . mysql_error());
mysql_select_db($dbname, $db);

$sql = "SELECT $blob_id, $blob_data FROM $blob_table";
echo $sql;
$result = mysql_query($sql);

header('Content-Type: text/html; charset=utf-8');

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $id = $row["$blob_id"];
    $data = $row["$blob_data"];
    $file = "$basedir$id.$type";
    echo "Looking for File: $file&lt;br&gt;";
    if (!file_exists($file)) {
        $fp=fopen($file,"w");
        echo "Opening File: $file&lt;br&gt;";
        fwrite($fp,$data);
        echo "Writing File: $file&lt;br&gt;";
    } else {
        echo "Skipping File: $file&lt;br&gt;";
        fclose($fp);
        echo "Closeing File: $file&lt;br&gt;";
    }
    sleep(1);
}

mysql_free_result($result);
?&gt;
</code></pre>

<p>can the images be encoded or something?</p>

<p>cause i just wasted 2 days trying to figure this thing out before posting and seeking help</p>