passing variables

Discussion in 'HTML' started by don, May 17, 2005.

  1. don

    don Guest

    echo "<iframe class=\"iframe\" width=\"600px\" height=\"230px\"
    src=\"search_table.php?description=\"" . $description . "\">";


    I tried to echo out the passed variable description in search_table.php but
    it did not appear????
    don, May 17, 2005
    #1
    1. Advertising

  2. In article <d6btji$k24$>, says...
    >
    >
    > echo "<iframe class=\"iframe\" width=\"600px\" height=\"230px\"
    > src=\"search_table.php?description=\"" . $description . "\">";
    >
    >
    > I tried to echo out the passed variable description in search_table.php but
    > it did not appear????


    Is it actually passed? What's the src attribute set to when you view
    the source of the loaded parent page?

    --
    Hywel

    Kill the Crazy Frog
    http://www.petitiononline.com/crzyfrg/
    Hywel Jenkins, May 17, 2005
    #2
    1. Advertising

  3. don wrote:
    > echo "<iframe class=\"iframe\" width=\"600px\" height=\"230px\"
    > src=\"search_table.php?description=\"" . $description . "\">";
    >
    >
    > I tried to echo out the passed variable description in search_table.php but
    > it did not appear????


    Perhaps REGISTER_GLOBALS is off. Does $_REQUEST['description'] work?
    Leif K-Brooks, May 17, 2005
    #3
  4. don wrote:

    > echo "<iframe class=\"iframe\" width=\"600px\" height=\"230px\"
    > src=\"search_table.php?description=\"" . $description . "\">";


    Which will come out as something like:

    <iframe class="iframe" width="600px" height="230px"
    src="search_table.php?description="YOURDESCRIPTION">

    So, you've mixed up your CSS tutorials and your HTML tutorials. The height
    and width attributes take either an integer, or an integer followed by a
    percentage sign - not an integer followed by the characters "px". (This
    isn't something that validation could pick up).

    What validation could have picked up, was the extra quotation mark in the
    output, you could probably have picked that up just by looking at the code
    your script was outputting.

    Try:

    ?>
    <iframe class="iframe" width="600" height="230"
    src="search_table.php?description=<? php
    echo htmlentities(urlencode($description));
    ?>">
    Alternative content
    </iframe>
    <?php

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, May 17, 2005
    #4
  5. don

    Gazza Guest

    David Dorward mumbled the following on 17/05/2005 08:19:
    > don wrote:
    >
    >
    >>echo "<iframe class=\"iframe\" width=\"600px\" height=\"230px\"
    >>src=\"search_table.php?description=\"" . $description . "\">";

    >
    >
    > Which will come out as something like:
    >
    > <iframe class="iframe" width="600px" height="230px"
    > src="search_table.php?description="YOURDESCRIPTION">


    ....which also appears to have an extra quote mark within the src itself.

    > Try:
    >
    > ?>
    > <iframe class="iframe" width="600" height="230"
    > src="search_table.php?description=<? php
    > echo htmlentities(urlencode($description));
    > ?>">
    > Alternative content
    > </iframe>
    > <?php


    or, purely in PHP:
    <?php
    $description = htmlentities(urlencode($_REQUEST['description'];
    echo '<iframe class="iframe" width="600" height="230"
    src="search_table.php?description="'.$description.'">';
    ?>

    There's no need to echo everything with double quotes ("), as most of it
    is just a string, so you can save a little bit of processing time by
    making PHP parse it as just a string, and not evaluate it for any PHP
    inside of it, by using single quote instead ('). It also makes the code
    neater by saving having to escape double quotes inside the string.

    --
    Gazza
    Mobile Number Network Checker - http://mnnc.net/
    Creative writing & Poems - http://garyjones.co.uk/
    Leovanna Leonbergers - http://leovanna.co.uk/
    Gazza, May 17, 2005
    #5
  6. While the city slept, Gazza () feverishly
    typed...
    > or, purely in PHP:
    > <?php
    > $description = htmlentities(urlencode($_REQUEST['description'];
    > echo '<iframe class="iframe" width="600" height="230"
    > src="search_table.php?description="'.$description.'">';


    or even...

    <?php
    // whatever else is in here...
    $description = htmlentities(urlencode($_REQUEST['description'];
    ?>

    <iframe class="iframe" width="600" height="230"
    src="search_table.php?description="<?=$description">

    Cheers,
    Nige

    --
    Nigel Moss http://www.nigenet.org.uk
    Mail address will bounce. | Take the DOG. out!
    "Your mother ate my dog!", "Not all of him!"
    nice.guy.nige, May 17, 2005
    #6
  7. don

    Gazza Guest

    nice.guy.nige mumbled the following on 17/05/2005 10:31:
    > While the city slept, Gazza () feverishly
    > typed...
    >
    >>or, purely in PHP:
    >><?php
    >>$description = htmlentities(urlencode($_REQUEST['description'];
    >>echo '<iframe class="iframe" width="600" height="230"
    >>src="search_table.php?description="'.$description.'">';


    > or even...
    >
    > <?php
    > // whatever else is in here...
    > $description = htmlentities(urlencode($_REQUEST['description'];
    > ?>
    >
    > <iframe class="iframe" width="600" height="230"
    > src="search_table.php?description="<?=$description">


    Although this relies on having short_tags enabled, which one can't
    assume. Some hosts are actually disabling this by default now, along
    with global variables, magic_quotes_gpc etc.

    And your final line should be:
    src="search_table.php?description=<?=$description;?>">
    --
    Gazza
    Mobile Number Network Checker - http://mnnc.net/
    Creative writing & Poems - http://garyjones.co.uk/
    Leovanna Leonbergers - http://leovanna.co.uk/
    Gazza, May 17, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Bazarov
    Replies:
    25
    Views:
    845
    E. Robert Tisdale
    Mar 23, 2005
  2. Replies:
    9
    Views:
    925
  3. pereges
    Replies:
    7
    Views:
    421
    pereges
    Jun 1, 2008
  4. Ramon F Herrera
    Replies:
    8
    Views:
    467
    Pascal J. Bourguignon
    Sep 13, 2009
  5. deadpickle
    Replies:
    1
    Views:
    951
    Jens Thoms Toerring
    Nov 7, 2010
Loading...

Share This Page