Jump to content

Inserting variables in a link, so that it works


phpretarded

Recommended Posts

 

 

Hello, this is about ' and this "" and this . the typical characters that I never know how to put in a string so that it works. I have this url string and I have hardcoded the names of the languages, but I need them replaced by a variable $estonia $from $into

 


echo '<a href="?country=Estonia&from_language=Russian&into_language=Latvian&submitted=true&
page='.$x. '">'.$x.'</a> ';

 

does anybody know how to embed those variables $ where the name of the country and the languages are ? and another thing. How would you embed in there something like $_GET['country']

 

So, the questions would be 2. One for the scalar variable $ and the other for the super global $_GET['country']

 

 

thanks a lot

 

 

A

Link to comment
Share on other sites

if I get your question right, you should use something like this to make it simple, and avoiding confusion about single quote and double quote

 

echo "<a href=\"?country=".$_GET['country']."&from_language=Russian&into_language=Latvian&submitted=true&
page=".$x. "\">".$x."</a>;"

 

for inserting any special character as text, just use "\CHARACTER" .. e.g. "\$"

Link to comment
Share on other sites

 

IT WORKED!!

 

Man, you deserve a medal. I had been stuck with this for 2 days, I have been in other forums and people either would mock at my question or would provide half way complicated solutions about http build query functions leaving me stuck in a swamp of mud. And look at your solution, you enclosed the variables in curly brackets and that was it. Now I know forever how to isolate these things.

 

thank you!!

Link to comment
Share on other sites

 

 

Thank you, hm, but I copied and pasted the link and it gives me this error

 

 

Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\translators19.php on line 131

 

 

which I did not get before pasting it.

 

good that ur problem is resolved ..

 

Nevertheless, I put end semi-colon inside quote ...  stupid typing mistake ..

 

echo "<a href=\"?country=".$_GET['country']."&from_language=Russian&into_language=Latvian&submitted=true&
page=".$x. "\">".$x."</a>";

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.