OK..I've got a variable...$tableName...and it's set through a case statement (drop down box) depending on which table the user wants to browse. Now, I've set this up in a php script called globals but when the user selects the table they want cool, it connects and gives them correct result. But if they try to modify it, the variable $tableName returns as "none", the default by the way. Now I see that the variable is out of scope but using
<PRE>

switch ($GLOBAL(["tablechoice=MyTable"]) {

     case "m":
	        $tableName="MyTable";
	break;
case "y":
	        $tableName=YourTable"";
	break;
case "o":
	        $tableName="OurTable";
	break;
default:
                              $tableName="none";
	break;

}

</PRE>

returns the same error?? So I might want to try $HTTP_POST_VARS?? How? Or si there a better way? All input welcome and appreciated!

Marcel.

    Also, I want to add, that the original selection from the user is posted, as a form action. Hence the thought of using $HTTP_POST_VARS. But I'mnot clear on how I should? Suggestions...ideas....life raft?

    Marcel.

      are you trying to preserve the value of the variable across multiple pages?

      if so, you have to either explicitly pass it from page to page, or use a session variable.

      --
      rad

        Yes I am, and thats my question, how do I explicity pass?

        Marcel.

          OK I decided on breaking the ice and trying sessions. Now cool I got it to pass a var across the pages but what if I want to alter this var and then pass it...don't I have to keep $session_var = "my_var" right below session_start(); ? For example:

          <PRE>

          <?php

          //globals.php

          session_start();
          $sess_var = "tableChoice"; <---i want this to pass $tableName to next page?
          session_register("sess_var");

          $hostName = "xxxxx"; // Where MySQL is running.
          $userName = "xxxx"; // user name needed to connect.
          $password = "xxxx"; // password for MySQL authentication.
          $databaseName = "xxxxx"; // database name.
          switch ($tableChoice) {

          case "c":
          	        $tableName="MyTable";
          	break;
          case "r":
          	        $tableName="YourTable";
          	break;
          case "s":
          	        $tableName="OurTable";
          	break;
          default:
                		$tableName="none";
          	break;

          }

          ?>

          </PRE>

          Now in my next page I use:
          <PRE>

          <?php

          session_start();

          $selectStmt = "SELECT * FROM $sess_var WHERE ROWID=$rowid " ;
          .
          .
          .
          .
          ?>
          </PRE>

          Obviously this isn't working and I know it's because I'm not directly passing the
          variable tableName...through tableChoice....what I think I need to do is...

          <PRE>
          session_start();
          $sess_var = switch ("tableChoice") {

          case "c":
          	        $tableName="MyTable";
          	break;
          case "r":
          	        $tableName="YourTable";
          	break;
          case "s":
          	        $tableName="OurTable";
          	break;
          default:
                		$tableName="none";
          	break;

          }
          session_register("sess_var");

          $hostName = "xxxxx"; // Where MySQL is running.
          $userName = "xxxx"; // user name needed to connect.
          $password = "xxxx"; // password for MySQL authentication.
          $databaseName = "xxxxx"; // database name.

          ?>

          </PRE>

          ...but will this work....or is there a better way? Doesn't seem correct to me? I'll try and see but in the meantime any help appreciated!

          thanks, Marcel.

            Nope giving me a parse error on line 6...$sess_var = switch ("tableChoice") { ! Hmmmmm....ok, I need help-where's Vincent when I need him? Or Louie? Or Rad..where'd you go??

            Marcel.

              7 months later

              hi,
              if you want pass value of $sess_var, you must assign a value for it:
              session_start();
              $sess_var = "tableChoice"; //<=WRONG, because you need result table from switch
              session_register("sess_var");

              $hostName = "xxxxx"; // Where MySQL is running.
              $userName = "xxxx"; // user name needed to connect.
              $password = "xxxx"; // password for MySQL authentication.
              $databaseName = "xxxxx"; // database name.
              switch ($tableChoice) {

              case "c":
              $tableName="MyTable";
              break;
              case "r":
              $tableName="YourTable";
              break;
              case "s":
              $tableName="OurTable";
              break;
              default:
              $tableName="none";
              break;
              }

              $sess_var = $tableName;//get value for next page using, or you can assign directly $sess_var =MyTable,.. each case in switch

              or you can use Setcookie

                Aaaahhhh...yesss! Thank you. I worked around that problem but will now go back and "fix" it the way I intended in the first place. To be honest I had forgotten about that question/problem, thanks again for the memory jog and the help. 🙂

                Marcel.

                  Write a Reply...