chonk Posted April 10, 2013 Share Posted April 10, 2013 I have a page that makes a call to an outside php page that creates a txt file and stores it on the server, attaches the file to an email then deletes it. Everything works except the bolded line of:exec('/home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&save=1'); I initially tried using this:<img src='/CreateDealerCatalogDB.php?ID=$DealerID&save=1' width='1' height='1'>which worked but only after submitting twice as the <img> tag got executed AFTER the php. Everything I read says the "exec()" function is what I want to do but I can't for the life of me figure out why it doesnt work. Heres what I have: $text = "$TransDesc \n\n $CustomizationInfo"; if($includeLogo == "1"){$path_of_logo = "../../images/dealers/dealerLogos/hires/$LogoHi";} if($includeDB == "1"){ //create a copy of catalogDB to attach exec('/home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&save=1'); $path_of_db = "../../images/dealers/db$DealerID.csv"; } $from = "info@xxx.com"; $subject = "Dealer Order"; $email = "info@xxx.com"; $to = "info@xxx.com"; include_once('../../PEAR/PEAR/Mail.php'); include_once('../../PEAR/PEAR/Mail/mime.php'); $message = new Mail_mime(); $message->setTXTBody($text); //$message->addAttachment($path_of_logo); $message->addAttachment($path_of_db); $body = $message->get(); $extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$email); $headers = $message->headers($extraheaders); $mail = Mail::factory("mail"); $mail->send($to, $headers, $body); if($includeDB == "1"){ //destroy created db exec('/home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&delete=1'); And again the flow is: My php page executes an outside file with the path of /home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&save=1' outside file creates a txt file on my server php page attaches file to mail.sends php file deletes txt file Any help will be greatly appreciated as i've struggled for an entire day on this already. Quote Link to comment Share on other sites More sharing options...
requinix Posted April 10, 2013 Share Posted April 10, 2013 exec() is for executing files. There is no such file as "CreateDealerCatalogDB.php?ID=123&save=1". There is one called "CreateDealerCatalogDB.php" though. Why not just include() the file normally? $get = $_GET; // save old values $_GET["ID"] = $DealerID; $_GET["save"] = 1; include $_SERVER["DOCUMENT_ROOT"] . "/CreateDealerCatalogDB.php"; $_GET = $get; // restore Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted April 10, 2013 Share Posted April 10, 2013 (edited) @regunix, I think he wants to execute a php GET variable by terminal. My suggestion: <?php $DealerID = $_GET['DealerID']; //create a copy of catalogDB to attach exec("php-cgi -f /home/terra/public_html/CreateDealerCatalogDB.php ID=$DealerID save=1"); Edited April 10, 2013 by jazzman1 Quote Link to comment 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.