I'm a bit befuddled on this, as by everything I can see, this should work... but it's not. I'm missing something elemental, and it's probably staring me right in the face. The variable $m equals 'big.' Here's my code thus far:

      $contents="                echo \"<li><a href=\\\"../".$m.".php"
      ."?lg=\""
      .".$_GET[lg]."
      ."\""
      ."\\\">".$m."</a></li>\";\r\n"

Here's what I was expecting:

                echo "<li><a href=\"../big.php?lg=".$_GET[lg]."\">big</a></li>";

Here's what I got:

                echo "<li><a href=\"../big.php?lg=".."\">big</a></li>";

It's missing the output of the $_GET ... it seems as if it's trying to DO the get, rather than place the word in the string. Can anybody untie this knot?

    you missing the quotes around the associative key in $_GET variable.

      igorek;10959863 wrote:

      you missing the quotes around the associative key in $_GET variable.

      They aren't needed when referencing an array item inside a double quote delimited string. In fact, adding them in such a case would cause an error.

      @: Are you trying to get the string $_GET[lg] to appear literally in the string, rather than have PHP do variable interpolation? If so, either escape the dollar sign in the string, or delimit the string with single quotes so that PHP doesn't do variable interpolation at all.

        You mean, do \$_GET[lg]

        or have the whole line

        .".$_GET[lg]." 
        

        done like this?

        .'.$_GET[lg].'
        

        Which would you recommend?

        I want the line to be literal.

          Yeah, that did the trick - encasing the whole line in ' ' rather than " ".

          However, for those interested...
          putting the \r\n escape characters inside single quotes does not work properly. Additionally, if you have any double quotes you want as part of the string, just put the double quotes WITHOUT the escape () character. Otherwise, the \ gets interpreted along with everything else.

          So single quotes (' ') work for literal strings, and double quotes (" ") work for processed info and everything else.

          BTW... Anyone working with Expression Web? Be VERY careful of unseen coding (BOM) that EW puts in its files. This code REALLy screws things up (as I found out the hard way with this edit). I kept getting errors I couldn't see, which were being interpreted by the php code. These errors stemmed from invisible BOM characters EW put into the code. Once I got rid of these characters, the rest worked fine.

          For more info on how to solve this problem, go to:
          http://www.95isalive.com/expression/index.html

          Thanks for all your help, guys!

            Write a Reply...