Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > passing variables

Reply
Thread Tools

passing variables

 
 
don
Guest
Posts: n/a
 
      05-17-2005


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
 
 
 
 
Hywel Jenkins
Guest
Posts: n/a
 
      05-17-2005
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/
 
Reply With Quote
 
 
 
 
Leif K-Brooks
Guest
Posts: n/a
 
      05-17-2005
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?
 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      05-17-2005
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
 
Reply With Quote
 
Gazza
Guest
Posts: n/a
 
      05-17-2005


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/
 
Reply With Quote
 
nice.guy.nige
Guest
Posts: n/a
 
      05-17-2005
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!"


 
Reply With Quote
 
Gazza
Guest
Posts: n/a
 
      05-17-2005


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="'.$descriptio n.'">';


> 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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is difference between Class variables and Instance variables? rahul8143@gmail.com Java 10 06-06-2011 06:43 AM
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Session Variables and Static Variables cobus.lombard@gmail.com ASP .Net 1 03-26-2006 11:05 AM
Accessing class member variables - properties or variables? dwok Java 7 03-04-2005 03:54 AM
Re: Class public shared Variables vs. Application Variables in ASP.NET avnrao ASP .Net 0 05-07-2004 05:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57