Echo an iframe with a html src that has a php variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kierandes
    New Member
    • Apr 2008
    • 25

    Echo an iframe with a html src that has a php variable

    Hey Guys,
    I am trying to make a iframe that changes depending on variables I call from a database. The database is working, variables are filling up, but I am having trouble with the echoing a iframe with the php variables within it. With some help from Markus I've made some progress but my attempts so far have been unsuccessful.

    Code:
    echo "<iframe SRC=/"http://www.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=\"\" , $lat_mins , ".width=/"100%/" height=/"100%/" frameborder=/"0/">If you can read this your browser does not support iframes</iframe>" ;
    in the above attempt I am trying to concatenate the PHP variable to the html src for the iframe, but I get the following error:

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

    its probably something I'm missing, any ideas guys?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Instead of having to escape the nested double quotes, use single quotes. Also, when using double quoted strings, you don't need to concatenate a variable into a string.

    Consider the below:

    Code:
    echo "My name is 'Mark'. {$vars} can be put in without {$needing} to concatenate the ${string}.";
    You get the error because you haven't properly escaped the nested double quotes (you used a forward slash instead of a backslash).

    - mark.

    Comment

    • kierandes
      New Member
      • Apr 2008
      • 25

      #3
      Originally posted by Markus
      Instead of having to escape the nested double quotes, use single quotes. Also, when using double quoted strings, you don't need to concatenate a variable into a string.

      Consider the below:

      Code:
      echo "My name is 'Mark'. {$vars} can be put in without {$needing} to concatenate the ${string}.";
      You get the error because you haven't properly escaped the nested double quotes (you used a forward slash instead of a backslash).

      - mark.
      Thanks Bud, did the trick :).

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by kierandes
        Thanks Bud, did the trick :).
        Welcome.

        - mark

        Comment

        Working...