Jump to content

Can you see the coding flaw - I can't


jm33990

Recommended Posts

I've stared at this way to long an would be happy (and probably embarrassed) if you can show me the flaw.

Maybe there is no error and I'm doing something illegal....??

 

I'm using a radio button to group two items together. These items show perfectly on the web page but are not returned properly to the posting program.

The first item is shown on the web page and posted back to the same program for processing.

The second item is shown on the web page but NOT posted back to the same program for processing.

They both share the same radio button name.

 

  foreach ($result as $line) {

      list($d1,,,$type,$d2) = split('  +',$line);

      if ($type == "CNAME") {

        list($alias,$discard) = split('[.]',$d1);

        echo "<br>";

        echo "<input type=radio name=\"del\" value=\"#$alias\">$alias";

        }

      echo "</table>";

      }

  echo "<br><br>Comments..<br>";

  foreach ($result as $line) {

      list($d1,,,$type,$d3) = split('  +',$line);

      if ($type == "TXT") {

        echo "<input type=radio name=\"del\" value=\"$d3\">$d3";

        echo "<br>";

        }

      }

After submit the same program pulls the posted info...

  $itemdelete = $_POST['del'];

  echo "startup itemdelete is $itemdelete ...<br>";

If it's $alias passed it's posted OK...if $d3 passed it's empty....why

 

Thank You.

 

Link to comment
Share on other sites

I realize that only the selected one is returned

The problem is if the TXT item is selected the $d3 value does not get returned.

If a CNAME item is selected the #$alias value is returned.

I know in both cases it is set properly because I can see them on the web page beside the buttons

thanks anyway for the help

Link to comment
Share on other sites

I changed value=\"$d3\" to value=$d3

why that matters yet value=\"#$alias\" is acceptable is a mystery to me...anyone care to explain.

 

summary

value=\"$d3\ --- does not work

value=$d3 --- works

value=\"#$alias\" --- works

value=#$alias ---- works

 

wierd..must be something to do with #

 

 

 

 

Link to comment
Share on other sites

One reason why variable interpolation is confusing. It's hard to tell if you meant the variable $d or $d3. Of course, $d may be undefined, but so what? No one knows what you mean. Try putting braces around the variable if you interpolate them, such as {$d3}. But it's best to just not interpolate them. I suggest string concatenation or string formatting with sprintf or printf.

Link to comment
Share on other sites

you lost me....

 

I thought my original post (and post #3) made it clear we were talking about $d3.

 

I still don't know why \"$d3\" fails and \"#$alias\" does not for value= on a radio button??

 

anyway it's working now that I removed the \" that was wrapped around the value= parameter's

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.