Jump to content


Photo

Variable in Another File


  • Please log in to reply
3 replies to this topic

#1 gladiator83x

gladiator83x
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 13 June 2006 - 08:20 PM

Hey All,

I have two pages and I am trying to pass a variable called $hlink from page1.php to page2.php. I was just wondering if someone could help me out? This is what I have been using:

On page1.php:

<php

echo '<a href="page2.php?string11= . $hlink . ">String is:</a>';

?>

<?php

On page 2 I have :

if (isset ($_GET['string11'])) echo $_GET['string11'];

?>

My variable $hlink stores a title that I want to bring up again on page2.php; however, the only thing that pops up is the output ".$hlink." Any suggestions?

#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 13 June 2006 - 08:25 PM

echo "<a href=\"page2.php?string11=$hlink\">String is:</a>";
z..z..z..z..z..z..z..z..

#3 gladiator83x

gladiator83x
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts

Posted 13 June 2006 - 08:57 PM

[!--quoteo(post=383455:date=Jun 13 2006, 04:25 PM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 04:25 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
echo "<a href=\"page2.php?string11=$hlink\">String is:</a>";
[/quote]


Thanks Joquius!!! That definitely worked [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 13 June 2006 - 09:07 PM

You can also do it without escaping the double quotes...
<?php echo '<a href="page2.php?string11=' . $hlink . '">String is:</a>'; ?>
You'll notice that I added a single quote after the "=" and before the following double quote in your original code.

Ken





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users