Create dynamic variable names in script form with new PHP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Create dynamic variable names in script form with new PHP

Postby AAA123 » 02. April 2014 08:39

Hi Everybody smart!
The case concerns the late determining dynamic variable names in script form that contains new versions of PHP

Variable is the created name of input field type=checkbox in the form defined as: $opcja_ row_z [0]
where $row_z [0] is unknown generated somewhere else. (ie. 29, 311, 108 ...etc).
Here for a simplicity we assumed $row_z [0] = 29;

[size = 2] This script works well in WAMP5 (Apache1.3, PHP 5.04)
while in XAMPP 1.8 (Apache2.4, PHP 5.47) does not recognize
interpreted the variable name opcja_29 received
from checkbox form [/size]
When I mark the checkbox on and send the form I got the folliwing on the screen:

$_GET Array ( [opcja_29] => on )
opcja_29 : // <--- HERE SHOULD BE opcja_29 : on -- BUT NOT, WHY ? ? ?

Notice: Undefined variable: opcja_29 in C:\xampp-portable\htdocs\4-00.php on line 12

The state of checkbox "on" is delivered in $_GET but I cannot display it.
I may do echo $_GET['opcja_29'] , but "opcja_XX" is generated dynamicly, (so no solid variable name)
Could anyboby help to fix the issue?
And here is the code "4-00.php"
Code: Select all
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-2">
<?php                    $row_z[0]=29;   
      $tmp = "opcja_$row_z[0]";

{ $temp = $_GET[$tmp];}else{ $temp = ""; }

  if ($temp) {
     echo"<br> opcja_$row_z[0]"; echo" : ";
     echo ${"opcja_$row_z[0]"};    
     print '<br><A HREF="4-00.php">Powrót do formularza</A>';
  } else {           
    echo "<br> No data entered  <br>";
    print '<FORM ACTION="4-00.php" METHOD=GET>';
    //  print '<INPUT TYPE="text" NAME="opcja_29">';
    print("<input type=checkbox name=\"opcja_$row_z[0]\" >");
         print '<INPUT TYPE="submit" VALUE="Send">';
         print '</FORM>';

Posts: 15
Joined: 30. December 2010 12:52

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 80 guests