< ?php
$location="/home/jgoddard/Desktop/images/";
$db = mysql_pconnect("localhost","user","password");
mysql_select_db("images",$db);
$sql="SELECT imageid, image from images";
$rs = mysql_query($sql,$db);
echo "<h2>EXPORTING INTO $location</h2>";
$counter=0;
while ($row=mysql_fetch_object($rs)) {
$filename=$location.$row->imageid.”.jpg”;
$file=fopen($filename,’w');
if (fwrite($file,$row->image)) {
echo $filename.”<br />”;
$counter++;
}
}
echo “<h2>$counter images exported</h2>”;
? >