RayJ Posted December 21, 2007 Share Posted December 21, 2007 I'm trying to set up a prototype for my company on a new project. This simple system needs to be accessed through the web, and PHP seemed like the best language for my needs. The following PHP code takes two inputs (currently from dropdown menus) and runs them through the code. The plan is to send both variables to teh corresponding C++ program. The C++ program operated correctly when run from the command line (currently running on Windows XP as I'm just testing out the architecture on my personal machine) but when I use the same syntax to run through the passthru() function, it does not display the information properly. If I ahrd-code the variables in the C++ program, the ouput gets displayed as intended, so I'm assuming it's a problem with my PHP code. Without further ado, here's my basic code: <?php $age = $_POST["age"]; $gender = $_POST["gender"]; print "Your age is ".$age."."; print "<br />"; print "Your are ".$gender." in gender."; print "<br />"; print "<br />"; $command = "C:\Program Files\Microsoft Visual Studio\MyProjects\InputTest\Debug\InputTest.exe ".$age." ".$gender.""; passthru(escapeshellarg($command)); ?> The PHP print statements show up with this formatting, but the raw output from the C++ program does not. I've messed with some other configurations of where to place the variables and get similar results (or the code breaks and displays nothing at all) Quote Link to comment https://forums.phpfreaks.com/topic/82729-passing-a-couple-variables-from-php-to-c/ 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.