Jump to content

Sonzai

Members
  • Posts

    10
  • Joined

  • Last visited

Sonzai's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. php calling script define("logdir", "/var/www/html/"); $toDebugger = logdir."OUT".$_SESSION['uniqueID']; $fromDebugger = logdir."IN".$_SESSION['uniqueID']; $fileCheckO = stat($toDebugger); $fileCheckI = stat($fromDebugger); if(($fileCheckO == 0)&&($fileCheckI == 0)) { system("./interfaceg ".$_SESSION['uniqueID']." > output.txt &"); usleep(10000); } else { if(($fdtoDbg = fopen($toDebugger, 'w')) == 0 ) print "not opened"; //put error here if(($fdfrmDbg = fopen($fromDebugger, 'r')) == 0) print "not opened"; //put error here } Warning: stat(): stat failed for /var/www/html/OUTstandinID in /var/www/html/compile_debug.php on line 36 Warning: stat(): stat failed for /var/www/html/INstandinID in /var/www/html/compile_debug.php on line 37
  2. Hello, I have a program in which I make a call to stat() simply to determine whether a file exists, which it initially doesn't - the next time the program is called it will exist but I am still getting a warning - I am passing an absolute path to state and the files in questions are pipes to a C process. Any suggestions/ideas? additionally, everything exists in the same directory Thank you for any and all help!
  3. Hi guys, Like the title says, for some reason SIGINT is not being caught and ending the process when it is sent. <?php define('logdir', '/var/www/html/Project2'); $pid = getmypid(); function catch_sigint($sig_num) { print('got a signal sigint\n'); flush(STDOUT); pcntl_signal(SIGINT, "catch_sigint"); posix_kill($pid, SIGINT); exit(1); } if((count($argc) < 1 )||(count($argc) >=2)) { print("usage: webserver idcode"); exit(1); } pcntl_signal(SIGINT, "catch_sigint"); while(1) { print "running"; sleep(3); } ?> If it's any insight, I had an interesting problem with getting the pid - I originally tried posix_getpid() but it gave an error saying that it was undefined though I'm running this on a Linux machine. The webserver env. is Apache. Thanks for any and all help!
  4. Aha! This project is making me miss simple things... Thanks .josh - and I think I do need to use exec because though the above is just a test, I will be using the real script to run C programs...but if you have any input on this I'd take it.
  5. Hello! So I am back to using PHP...and back to having questions about it I am not understanding how to execute a php script from the command line and properly pass variables. the syntax is php -f <file> [args] I understand, but I have been receiving the error below when I try to execute the following test code. launcher.php: <?php $argv[1] = "first argument"; $argv[2] = "second argument"; $simple ="simple"; exec(php -f launched.php simple); ?> launched.php <?php $stdout = fopen('php://stdout', 'w'); fwrite($stdout, $argv[1]); fwrite(STDOUT, $argv[1]); ?> ~ The error I receive when running: php launcher.php is the following- Parse error: syntax error, unexpected T_STRING in /var/www/html/Project2/launcher.php on line 7 *please note in launcher, I have tried passing simple as you see it, as well as by $simple and "simple" *I am running Apache Web Server environment with PHP CLI configuration.
  6. Coincidentally, I am having a similar (if not the same) problem. I have tested my code as well as could be, so I know that it does work as it should (pardon the idiom, but you know what I mean) however the session array is not maintaining it's variables. Apologies if I'm intruding on this post but this could shed some light on the issue...as well as allow me to piggyback on the responses I am not going to post any code but rather a schema, this may make things clearer: starting with First.php: --this contains a form that uploads a username,password and file, begins with <?php session_start(); ?><html>...</html> --method=POST action=Second.php at Second.php: --begins with session_start(); --correctly passes username and password and connects to the database using mysqli_connect(); --parses the file passed and checks the contents against the database(anything that exists in both is saved in an array: lets call that duplicates) --now in the $_SESSION array we save username, password, and duplicates --a new form 'update.php' is included --a hidden variable from the form is checked to see if the form was submitted NOTE: this creates the undefined index error --Second.php should continue, if the variable is set, to process the new data. -- the session is destroyed and the connection is closed in update.php -- session_start is called -- a form presents the values of the duplicates array and allows the user to select which to update in the database --method=post action="" comments so here is the blue print, I will post the code if preffered. but I have some observances of what is going on. After the include, the script continues to execute before presenting the form. If there is ANY WAY to pause a script, this would solve all my issues... I have even tried to sleep through a loop but this will not work as the script does not show the include until after the script has finished. anyhow, script executes and closes the database connection but does not destroy the session(this is certain as each script shows the same session id throughout). finally, the crux is that the $_SESSION array is empty after the update.php form submits... insight?
  7. I thought this important to post: This line echo ' <td><input type="checkbox" name="Updates[]" value="{$index}"></td> '; is intended to use the index as the value of the update, however in this form "{index}" is being passed as the value this format is needed to pass the value of the the index as a string echo ' <td><input type="checkbox" name="Updates[]" value=" '. $index .' "></td> ';
  8. Thank you very much for the effort, looking at your code has informed me of new "clearer" ways of doing things. In my hurry to get an example up, I left several errors so they may be the source of the problem, but here is the major irritation: Whenever I change the script so that it no longer is picked up by the parent, rather let's say the form posts to "phpto2.php" all I get is a print out of the code contained in that script. When the action returns to the calling script "phpfrom.php", the original form is still visible. Also, I believe this line is what caused the code to run correctly, but if there are multiple forms inputtting into the phpfrom.php script won't this be true for any number of them and not specifically phptp.php? $_SERVER['REQUEST_METHOD'] == 'POST' Lastly, form is an acceptable attribute for input types, however it references the form id rather than the name I believe, so I slipped up there
  9. This is the less simple, but more similar example of what I am doing to help those who would like a better example. ***phpfrom.php*** <?php $test1d = array("Name"=>NULL, "Age"=>NULL, "Sign"=>NULL); $test2d = array(); $test1d['Name'] = 'Haru'; $test1d['Age'] = NULL; $test1d['Sign'] = 'Pisces'; $test2d[] = $test1d; $test1d['Name'] = 'Shizuku'; $test1d['Age'] = 15; $test1d['Sign'] = NULL; $test2d[] = $test1d; $test1d['Name'] = 'Yamaken'; $test1d['Age'] = NULL; $test1d['Sign'] = NULL; $test2d[] = $test1d; include ('phpto.php'); if(isset($_REQUEST['test'])) { echo " the rest is gone"; $updates = $_REQUEST['Updates[]']; $nums = count($updates) -1; echo "number in updates[] ".$nums; if($nums >= 0) { $test2d[$nums]['Sign'] = 'Ophiuchus'; echo $test2d[$nums]['Name']."is now an Ophiuchus"; } } ?> includes this: ***phpto.php*** <html> <head></head> <body> <form method="POST" action="phpfrom.php" name="corrections"> <?php echo " <table cellpadding=5 > <tr><td><h3>Name</h3></td> <td><h3>Age</h3></td> <td><h3>Sign</h3></td> <td><h3>Update</h3></td> </tr>"; for($increm = 0; $increm < count($test2d); $increm++) { echo "<tr><td>".$test2d[$increm]['Name']."</td>"; if($test2d[$increm]['Age'] == NULL) { echo "<td><input type=\"text\" name=\"Ages[".$increm."]\" form=\"corrections\"></td>"; } else { echo "<td>".$test2d[$increm]['Age']."</td>" ;} if($test2d[$increm]['Sign'] == NULL) { echo "<td><input type=\"text\" name=\"Signs[".$increm."]\" form=\"corrections\"></td>"; } else { echo "<td>".$test2d[$increm]['Sign']."</td>";} echo '<td><input type="checkbox" name="Updates[]" value='.$increm.' form="corrections"></td></tr>'; } echo "</table>"; ?> <input type="hidden" name="test" form="corrections"> <input type="submit" value="submit" form="corrections"/> </form> </body> </html>
  10. Hello, I am hoping someone can help with this issue and even if not, clarify some questions I have been having. The two code files I am showing below are a simple mock-up of a larger project using the same concept. ***name.php*** <?php echo "some crap here"; include ('simple.php'); if(isset($_REQUEST['firstname'])) { $firstName = $_REQUEST['firstname']; $lastName = $_REQUEST['lastname']; echo 'Welcome to our website, ' . htmlspecialchars($firstName, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($lastName, ENT_QUOTES, 'UTF-8') . '!'; } ?> ***simple.php*** <html> <head></head> <body> <form name="simple" method="post" action="name.php"> <?php echo "please tell me your first and last name"; ?> <input type="text" name="firstname" id="firstname" form="simple"> <input type="text" name="lastname" id="lastname" form="simple"> <input type="submit" value="submit" form="simple"> </form> </body> </html> the idea is that I need to use some variables created before the include in generating the form in "simple.php" ...I know that is not really the case in this example but in the larger project I mentioned, it is. So I include the file to show the form and all seems well however the following problems occur 1) no data is picked up by $_REQUEST...(that I can see, I am imagining that after the include the script does not wait for the form return), and 2) though the action field in the form directs it to "name.php", it neither re-runs the script nor returns to the point at which it was included. I will try to reply to this with a more similar example if what I'm trying to do is unclear.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.