Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Passing PHP Variables

SpaceshipSpaceship
NamecheapNamecheap
Namecheap AuctionsNamecheap Auctions
Watch

freeflow

Established Member
Impact
13
Is there a way to solve the following problem?


PHP Script1:

$var1 = 'Free+Online+Games';

<a href="script2.php?q=<? echo "$var1";?>" <? echo "$var1";?></a>


PHP Script2:

$var1 = @$_GET['q'] ;

$var ="link.com/rss?p=var1$&ei=UTF-8&fl=0&x=wrt";


The Problem:

By the time Free+Online+Games reach the link in script2 the +s are gone.
How can I pass the words without the +s being deleted?

Thanks.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
urlencode it.
 
0
Close
Daniel said:
urlencode it.
E.g.

Code:
$var1 = 'Free+Online+Games';  
<a href="script2.php?q=<? echo urlencode($var1);?>" <? echo "$var1";?></a>
 
0
Close
Everyone is missing the closing tag (">") on the original link after the ending quote. It is also a good practice to use full opening php tags, not shorthand. Most configurations support these shorthands, but there are still some that do not. You can also use <?php=

Code:
<?php
$var1 = 'Free+Online+Games';  
?>
<a href="script2.php?q=<?php=urlencode($var1)?>"> <?php=$var1?></a>

Also an efficiency tip, freeflow:
When echoing just a variable, don't put it inside of " "

Code:
echo $var;
is faster than
Code:
echo "$var";
It isn't by much, but if you're writing a large script, any piece of efficiency you can pick up is worth it. It is also a much better "Habit".

I really enjoyed This Article that I found using StumbleUpon about php efficiency.


Bruce
 
0
Close
Or you could try escaping the +'s. I'm not sure if it would work in this case? But just add a "\" in front of the +'s.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back