hoopplaya4 Posted January 14, 2009 Share Posted January 14, 2009 Hey All, I'm trying to pass a PHP variable to another PHP script via Exec(). I am using Exec because I want to run the script in the background to do some processing. Here's what I currently have: $id=$_POST['name']; exec("php myscript.php?name=" . $id . " >> completed.php &"); Now, when I manually browse to the PHP script and run it, it works fine, however, it doesn't work when I try to "exec" it. It appears that the $id isn't passing. Is there something I'm doing wrong here? Or is there another way to pass the variable? Thanks! Quote Link to comment Share on other sites More sharing options...
flyhoney Posted January 14, 2009 Share Posted January 14, 2009 exec("php myscript.php $id >> completed.php &"); Should work. And to get id in myscript.php: $id = $argv[0]; Quote Link to comment Share on other sites More sharing options...
hoopplaya4 Posted January 14, 2009 Author Share Posted January 14, 2009 Thanks for the reply, flyhoney. That got me further, but now, it's actually passing "myscript.php" as the variable, not $_POST['name']. Quote Link to comment Share on other sites More sharing options...
hoopplaya4 Posted January 15, 2009 Author Share Posted January 15, 2009 Nevermind, got it figured out! Used "$argv[1];" instead! Thanks again! 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.