Jump to content

Variable in Another File


gladiator83x

Recommended Posts

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?
Link to comment
Share on other sites

[!--quoteo(post=383455:date=Jun 13 2006, 04:25 PM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 04:25 PM) [snapback]383455[/snapback][/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\" /]
Link to comment
Share on other sites

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

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.