[advanced search]
Results from the most recent live auction are here.
10 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 06-18-2008, 10:38 AM   · #1
freeflow
NamePros Member
 
Trader Rating: (0)
Join Date: Dec 2006
Posts: 112
NP$: 12.00 (Donate)
freeflow is on a distinguished road
Question Passing PHP Variables

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$&amp;ei=UTF-8&amp;fl=0&amp;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.


Please register or log-in into NamePros to hide ads
freeflow is offline   Reply With Quote
Old 06-18-2008, 10:42 AM   · #2
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 0.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
urlencode it.
Daniel is offline   Reply With Quote
Old 06-18-2008, 11:33 AM   · #3
edbrown
NamePros Member
 
edbrown's Avatar
 
Location: London
Trader Rating: (2)
Join Date: Dec 2006
Posts: 101
NP$: 141.10 (Donate)
edbrown is an unknown quantity at this point
Originally Posted by Daniel
urlencode it.


E.g.

Code:
$var1 = 'Free+Online+Games'; <a href="script2.php?q=<? echo urlencode($var1);?>" <? echo "$var1";?></a>
__________________
ejbrown.net - XHTML/CSS/AJAX/PHP/mySQL development
edbrown is offline   Reply With Quote
Old 06-18-2008, 12:16 PM   · #4
Bruce_KD
NamePros Member
 
Trader Rating: (1)
Join Date: Sep 2006
Posts: 77
NP$: 100.00 (Donate)
Bruce_KD will become famous soon enoughBruce_KD will become famous soon enough
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
Bruce_KD is offline   Reply With Quote
Old 06-19-2008, 12:50 AM   · #5
pankirk
NamePros Member
 
Name: Patrick
Location: California
Trader Rating: (2)
Join Date: Apr 2008
Posts: 45
NP$: 0.00 (Donate)
pankirk is an unknown quantity at this point
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.
pankirk is offline   Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
domainsubway.com Grow your forum! http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 04:55 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0