HighDots Forums  

passing variables

alt.html alt.html


Discuss passing variables in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
don
 
Posts: n/a

Default passing variables - 05-17-2005 , 12:57 AM








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????




Reply With Quote
  #2  
Old   
Hywel Jenkins
 
Posts: n/a

Default Re: passing variables - 05-17-2005 , 01:54 AM






In article <d6btji$k24$1 (AT) reader1 (DOT) panix.com>, don (AT) panix (DOT) com says...
Quote:

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/


Reply With Quote
  #3  
Old   
Leif K-Brooks
 
Posts: n/a

Default Re: passing variables - 05-17-2005 , 02:21 AM



don wrote:
Quote:
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?


Reply With Quote
  #4  
Old   
David Dorward
 
Posts: n/a

Default Re: passing variables - 05-17-2005 , 03:19 AM



don wrote:

Quote:
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


Reply With Quote
  #5  
Old   
Gazza
 
Posts: n/a

Default Re: passing variables - 05-17-2005 , 04:42 AM





David Dorward mumbled the following on 17/05/2005 08:19:
Quote:
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.

Quote:
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/


Reply With Quote
  #6  
Old   
nice.guy.nige
 
Posts: n/a

Default Re: passing variables - 05-17-2005 , 05:31 AM



While the city slept, Gazza (news (AT) garyjones (DOT) co.uk.invalid) feverishly
typed...
Quote:
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. nigel (AT) DOG (DOT) nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!"




Reply With Quote
  #7  
Old   
Gazza
 
Posts: n/a

Default Re: passing variables - 05-17-2005 , 05:39 AM





nice.guy.nige mumbled the following on 17/05/2005 10:31:
Quote:
While the city slept, Gazza (news (AT) garyjones (DOT) co.uk.invalid) 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/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.