Jump to content

DooVoo

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by DooVoo

  1. DooVoo

    Getting Fatal Error

    Have you declared the class/structure "VARIANT" anywhere in your code? The error seems to suggest not.
  2. Can you clarify, do you want to save the output of a PHP script or save the PHP script itself? I'm not sure why you would want to do the latter, but the former would be done by outputting to a file.If this is what you want to do, take a look at the fopen() and associated functions:http://uk2.php.net/manual/en/function.fopen.php
  3. Assuming you are sending your form data in POST your script might like something below: $string_array = str_split($_POST['A']); Then you can access each element of the array like so: print($string_array[0]); Hope that helps!
  4. From your example it looks like there are no delimiting characters to use with explode(). Instead try using the str_split() function.Details here: http://uk.php.net/manual/en/function.str-split.php
  5. It seems the session data was being set after the pages array so the session data wasn't available until after a refresh. Moving the pages array initialisation solved the issue. The code above works lovely now!
  6. Hi All,I've been wrestling with this problem for two days now and just cannot work out what the cause is! Below is a simple piece of code that is designed to return a view (for now, just simple html) depending on one of 3 states of the system. This state is stored in a SESSION var and is manipulated by the GET parameter 'cmd' (i.e. cmd=Next etc). With these commands, additional information can also be sent, these are automatically stored into the SESSION under the appropriate name (i.e. cmd=Next&name=Paul) the $_SESSION['name'] would be set to 'Paul'. This works fine for the first input but when an email address is given in state 2, the data is not shown in state 3 with the name from stage 1 (if that makes sense ). However, the data is being stored as when you refresh the page and redisplay stage 3 the data appears!The code snippit is below: <?session_start();/* Registration Form Script*/// Includes//include("includes/mysql.inc.php");// Constantsdefine("MIN_STAGE_COUNT","1");define("MAX_STAGE_COUNT","3");// Functionsfunction PrevStage(){ if ($_SESSION['Stage'] > MIN_STAGE_COUNT) $_SESSION['Stage']--;}function NextStage(){ if ($_SESSION['Stage'] < MAX_STAGE_COUNT) $_SESSION['Stage']++;}// Beginprint("DEBUG: Begin<br>");print("DEBUG: Checking Session<br>");if(!isset($_SESSION['Stage'])){ print("DEBUG: Stage not set. Defaulting to 1<br>"); $_SESSION['Stage'] = 1;}else{ foreach ($_GET as $field => $value) { print("DEBUG: Switching Field " . $field . ".<br>"); switch ($field) { case "cmd": switch ($value) { case 'Next': print("DEBUG: Command Next.<br>"); NextStage(); break; case 'Prev': print("DEBUG: Command Previous.<br>"); PrevStage(); break; } break; default: print("DEBUG: Unknown Param " . $field . "=" . $value . " - Storing to session.<br>"); $_SESSION[$field] = $value; break; } }}$Pages = array();$Pages[1] = '<h2>Enter your name...</h2> <form name="Form1"> <input type="textbox" name="name" id="name"> <input type="button" value="Next Stage" onClick="javascript: NextStage();"> </form>';$Pages[2] = '<h2>Please enter your email...</h2> <form name="Form2"> <input type="textbox" name="email" id="email"> <input type="button" value="Previous Stage" onClick="javascript: PrevStage();"> <input type="button" value="Next Stage" onClick="javascript: NextStage();"> </form>';$Pages[3] = '<h2>Welcome ' . $_SESSION['name'] . '!</h2> <p>You gave your email as: ' . $_SESSION['Email'] . '</p>';print($Pages[$_SESSION['Stage']]);print("DEBUG: Stage = " . $_SESSION['Stage'] . "<br>");print("DEBUG: End<br>");session_write_close();?> I'm guessing it has something to do when the way I am setting the session values and that the returned data is being returned before the session has been updated. I just can't see it. Any help would be hugely appreciated!
×
×
  • Create New...