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

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. "\$"

 

 

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.

 

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

 

 

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>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.