/    Sign up×
Community /Pin to ProfileBookmark

exec command not working?

Hi guys,

Trying to get make a zip file on the fly but I’m sure my paths (in the exec command) are not correct.

Help is greatly appreciated.

(safe is just a mysql_real_escape_string function so I don’t have to write that long function name each time.)

So what I’m trying to do is zip a folder to a zip file.

[code]
$id = safe($_GET[“id”]);
$sql = “select cmp_user, cmp_list, cmp_list_name, cmp_user, cmp_id from tbl_campaign where cmp_id = $id”;
$rs = mysql_query($sql);
if(@mysql_num_rows($rs) == 0){
echo “That campaign is invalid.”;
exit;
}
$r = mysql_fetch_assoc($rs);
$userid = $r[“cmp_user”];
$cmpfolder = “cmp_”.$r[“cmp_id”];
$cid = $r[“cmp_id”];
$zipto = “./content/$userid/campaign_$cid.zip”;
$dl = “campaign_$cid.zip”;
$zip_cmd = “zip -r $zipto ./content/$userid/$cid”;
exec($zip_cmd);
[/code]

This is a linux server running php 5.2.

Also, how can I see the error if it fails?

Thanks

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @saturnprods spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...