phpretarded Posted June 5, 2012 Share Posted June 5, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263692-inserting-variables-in-a-link-so-that-it-works/ Share on other sites More sharing options...
abdfahim Posted June 5, 2012 Share Posted June 5, 2012 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. "\$" Quote Link to comment https://forums.phpfreaks.com/topic/263692-inserting-variables-in-a-link-so-that-it-works/#findComment-1351340 Share on other sites More sharing options...
phpretarded Posted June 5, 2012 Author Share Posted June 5, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263692-inserting-variables-in-a-link-so-that-it-works/#findComment-1351345 Share on other sites More sharing options...
Barand Posted June 5, 2012 Share Posted June 5, 2012 echo "<a href='?country={$_GET['country']}&from_language=Russian&into_language=Latvian&submitted=true&page=$x'>$x</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/263692-inserting-variables-in-a-link-so-that-it-works/#findComment-1351347 Share on other sites More sharing options...
phpretarded Posted June 5, 2012 Author Share Posted June 5, 2012 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!! Quote Link to comment https://forums.phpfreaks.com/topic/263692-inserting-variables-in-a-link-so-that-it-works/#findComment-1351351 Share on other sites More sharing options...
abdfahim Posted June 5, 2012 Share Posted June 5, 2012 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/263692-inserting-variables-in-a-link-so-that-it-works/#findComment-1351359 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.