/    Sign up×
Community /Pin to ProfileBookmark

Problems with echo statement

Hello,

I am having an issue with an echo statement.

I am passing a string with $_GET and attempting to print it with echo. The issue is the content in the $_GET contains an & and when I echo the string it doesnt print the & or anything after it. For example,

the url which is sending the information is

[code=php]
http://www.realitytvaddict.com/read_post.php?tid=35&name=The%20Kardashians&subject=Kim%20&%20Kanye!%20Will%20it%20last?#1677
[/code]

[B]I have tried just echoing the $_GET[‘subject’]. I have also tried running it through htmlspecialchars(). I have also tried replacing the & with regrex but nothing seems to work.[/B]

Whenever I print out the variable it is turned from “Kim & Kanye! Will it last?” into “Kim”

Can anyone figure out why it is doing this?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 06.2012 — Either use htmlspecialchars() or htmlentities() on the text being output.
Copy linkTweet thisAlerts:
@mccoauthorOct 07.2012 — Tried htmlspecialchars, ended up with the same effect. Thats what I thought would fix the problem as well.
Copy linkTweet thisAlerts:
@NogDogOct 07.2012 — We may need to see a bit of the actual PHP code to better understand what you are trying to do. Maybe it's just a case of a HTML tag attribute's value not being quoted?
Copy linkTweet thisAlerts:
@mccoauthorOct 07.2012 — Figured it out. Just needed to add urlencode() to the variable before it was passed via $_GET. That allows the & to get passed and then I used htmlentitites() on the receiving end before echoing.
Copy linkTweet thisAlerts:
@Keyboard_KowboyOct 10.2012 — Can you post a tidbit of the code and I may be able to help you!
Copy linkTweet thisAlerts:
@manispiritOct 12.2012 — plz attach your code and i may be able to help u
×

Success!

Help @mcco spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...