Can't create a zip file with PHP
<p>I've created the following code to create a zip file. I'm pulling a list of files from the database depending on the $job_number (which I'm getting from the global $_GET array) and then trying to add them to the zip file.</p>

<p>That part is working fine. It's pulling the list of files from the database, as I can see by echoing or dumping with <code>print_r</code> the results.</p>

<p>The only problem is that the .zip file isn't being created at all. I can't see where I've gone wrong.</p>

<pre><code>$sth = $conn-&gt;prepare('SELECT `dp_filename` FROM damage_pics WHERE dp_job_number = :job_number');
$sth-&gt;bindParam(':job_number', $job_number);
$sth-&gt;setFetchMode(PDO::FETCH_ASSOC);
$sth-&gt;execute();

$zip = new ZipArchive();
$zip-&gt;open('example5.zip', ZipArchive::CREATE);
$result = $sth-&gt;fetchAll();


echo '&lt;pre&gt;';
print_r($result);

foreach ($result as $file)
{
    // just echoing for testing purposes to see if file name is created correctly.
    $image = $file['dp_filename'];
    echo $image . "&lt;br /&gt;";
    $zip-&gt;addFile("uploads/{$image}");
}

$zip-&gt;close();
</code></pre>
