swampone Posted April 19, 2010 Share Posted April 19, 2010 Im trying to pass multiple variables to a URL. I am able to get the first URL through, but not any others. $link_b = ("<a href=\"view.php?vkey=".$vkey."&title=".$meta."\">".$meta."</a>"); The value of vkey is seen in the url, but the value of title is not. The URL i get looks like the following: http://localhost/view.php?vkey=765297369 I need it to look like the following, so i can have access to variables on the new page: http://localhost/view.php?vkey=765297369&title=$meta Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/ Share on other sites More sharing options...
TeddyKiller Posted April 19, 2010 Share Posted April 19, 2010 Try this.. $link_b = ('<a href="view.php?vkey='.$vkey.'&title='.$meta.'">'.$meta.'</a>'); edit: It was bad code. corrected it now. Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/#findComment-1044619 Share on other sites More sharing options...
swampone Posted April 19, 2010 Author Share Posted April 19, 2010 Im getting the same results. Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/#findComment-1044624 Share on other sites More sharing options...
seventheyejosh Posted April 19, 2010 Share Posted April 19, 2010 What is in your get array? echo '<pre>'; print_r($_GET); echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/#findComment-1044628 Share on other sites More sharing options...
Psycho Posted April 19, 2010 Share Posted April 19, 2010 What are the values of $vkey and $meta? I'd use this: $link_b = "<a href=\"view.php?vkey={$vkey}&title={$meta}\">{$meta}</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/#findComment-1044630 Share on other sites More sharing options...
swampone Posted April 19, 2010 Author Share Posted April 19, 2010 Array ( [vkey] => 765297369 ) what is the tag for code for this site? Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/#findComment-1044634 Share on other sites More sharing options...
TeddyKiller Posted April 19, 2010 Share Posted April 19, 2010 Press the # button on the reply bit. Or use code /code - php /php surrounded by [ ] In your link, is $meta got the correct value as the name of the link, it's just not in the URL? Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/#findComment-1044639 Share on other sites More sharing options...
swampone Posted April 19, 2010 Author Share Posted April 19, 2010 Not sure why, but when I swapped the two variables around, it works just how I want it to. <?php //shows both the values of title and vkey $link_b = "<a href=\"view.php?title={$meta}&vkey={$vkey}\">{$meta}</a>"; //Only give me the value of vkey $link_b = "<a href=\"view.php?vkey={$vkey}&title={$meta}\">{$meta}</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/199017-passing-variables-through-url/#findComment-1044656 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.