Web Analytics Made Easy -
StatCounter Help with Embedded Quotes - CodingForum

Announcement

Collapse
No announcement yet.

Help with Embedded Quotes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with Embedded Quotes

    I'm trying to write a javascript line for a webpage link that will result in a popup window. The link must contain a php variable ($info) that can have embedded spaces.

    Here is what I have, but the $info is not being enclosed in quotes properly, and I can't seem to figure out how to do it.

    document.write(\"<div align='left'><a href=java_script_:window.open('$pathhref/targetscript.php?usrid=$usernumber&infoname=$info','PersonalInformation','width=400,height=250,statu s=no,resizeable=no,menubar=no,toolb ar=no,directories=no,location=no,scrollbars=no,allwaysraised=yes,top=40,left=150');void(0)>$info</a></div>\");

    Can someone please tell me how to get the quotes around $info? I'd be very grateful.

  • #2
    try

    PHP Code:

    <?php

    echo "<div align='left'><a href=java_script_:window.open('$pathhref/targetscript.php?usrid=$usernumber& infoname=$info','PersonalInformation','width=400,h
    eight=250,status=no,resizeable=no,menubar=no,toolb
    ar=no,directories=no,location=no,scrollbars=no,all
    waysraised=yes,top=40,left=150');void(0)>
    $info</a></div>";

    ?>
    As I think the way you were doing it, the PHP is being written as the actual... rather than being replaced....
    www.mattfacer.com

    Comment


    • #3
      Are you saying I don't need the document.write part at all? Or do I need to put the <? php ?> stuff inside it?

      Comment


      • #4
        can you post the HTML code of the whole page inc. the PHP stuff?
        www.mattfacer.com

        Comment


        • #5
          PHP Code:
          <div align='left'><a href=java_script_:window.open('<?php echo $pathhref?>/targetscript.php?usrid=<?php echo $usernumber?>&infoname=<?php echo urlencode($info);?>','PersonalInformation','width=400,h
          eight=250,status=no,resizeable=no,menubar=no,toolb
          ar=no,directories=no,location=no,scrollbars=no,all
          waysraised=yes,top=40,left=150');void(0)>"<?php echo $info?>"</a></div>
          Used the function urlencode to fill the spaces in $info with %20 and just added quotes the usual way.
          Last edited by Nightfire; Mar 4, 2004, 12:28 PM.

          Comment


          • #6
            that all looks ok to me?
            is there still a problem?
            www.mattfacer.com

            Comment


            • #7
              I could post it all, it's a php script, but it's a few hundred lines long. If you tell me what you need to see, I can pare it down a lot.

              I'll try the urlencode idea, will the target script recognize the blanks, because that $info field is used in the target script in a mysql select query.
              Last edited by Chick; Mar 4, 2004, 12:30 PM.

              Comment


              • #8
                to me, it looks like that code should be ok.... is it just not showing $info or something??
                www.mattfacer.com

                Comment


                • #9
                  I finally figured out how to make the URL behave correctly when the quoted field has more than 1 word (with a space between the words). There is a PHP function called rawurlencode and it replaces the space characters with %20 which is used in a URL.

                  Thanks to all who tried to help.

                  Comment

                  Working...
                  X