gavin.sibley Posted May 24, 2012 Share Posted May 24, 2012 hello, i am trying to get this code to select a set of links from a database and then add the to the folder to be zipped, everything seems to be working apart from it doesnt seem to pull the url's to add to the end of the file_get_contents line, anyone have any ideas? <?php include("config.php"); require ("zipfile.inc.php"); $zipfile = new zipfile(); $filedata = implode("", file("zipfile.inc.php")); $getspdi = mysql_query("SELECT * FROM `wedding_photos` WHERE `user_hash` = '$_GET[id]' ORDER BY `id` DESC LIMIT 0, 1000") or die(mysql_error()); $getspd = mysql_fetch_array($getspdi); while ($photos = mysql_fetch_array($getspdi)) { $zipfile->add_file(file_get_contents("/var/www/vhosts/mydomain.com/httpdocs-entertainment/wuploads/"), "$photos[img]"); echo("/var/www/vhosts/soundboxaudio.com/httpdocs-entertainment/wuploads/ <br />"); } header("Content-disposition: attachment; filename=spd_$_GET[title]_$_GET[fname]_$_GET[lname]__$_GET[photos]_Photos.zip"); echo $zipfile->file(); ?> many thanks, gavin Quote Link to comment https://forums.phpfreaks.com/topic/263052-build-an-array-from-database/ Share on other sites More sharing options...
requinix Posted May 24, 2012 Share Posted May 24, 2012 You're doing file_get_contents() on a directory. Think about that. Quote Link to comment https://forums.phpfreaks.com/topic/263052-build-an-array-from-database/#findComment-1348426 Share on other sites More sharing options...
gavin.sibley Posted May 24, 2012 Author Share Posted May 24, 2012 thanks for that, any chance you can point me in the right direction? i am not a web person in the slightest but have been given the task of fixing this site that someone else built! thanks, gavin Quote Link to comment https://forums.phpfreaks.com/topic/263052-build-an-array-from-database/#findComment-1348451 Share on other sites More sharing options...
piyusharora420 Posted May 25, 2012 Share Posted May 25, 2012 One more mistake. use while ($photos = mysql_fetch_array($getspd)) instead of while ($photos = mysql_fetch_array($getspdi)) Quote Link to comment https://forums.phpfreaks.com/topic/263052-build-an-array-from-database/#findComment-1348542 Share on other sites More sharing options...
requinix Posted May 25, 2012 Share Posted May 25, 2012 One more mistake. use while ($photos = mysql_fetch_array($getspd)) instead of while ($photos = mysql_fetch_array($getspdi)) Uh no. It should be $getspdi. However the $getspd = mysql_fetch_array($getspdi); line is a problem. It'll make the loop skip the first row in the resultset. Get rid of it. Quote Link to comment https://forums.phpfreaks.com/topic/263052-build-an-array-from-database/#findComment-1348663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.