/    Sign up×
Community /Pin to ProfileBookmark

passing string to next page

When trying to pass a string from one page to another, if the string contains white-spaces, only the part of the string before the first white-space is passed to another page.
For example:
page1.php

$str = “Hello Annette”;
echo “<a href=”page2.php?str=”.$str.”>Hello</a>”;

page2.php
..
$srt = $_GET[`str’];
echo “String:”.$str;

The result of this echo is only “Hi”. So the passed string becomes “Hi” instead of “Hi Annette”.

Please advise.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@Shanu_chaudharyApr 18.2008 — Hi...I dont know whether its correct...But May b it should be correct...

U need to replace the white space with %20 b4 passing it .....

As str_replace(" ","%20",$str);

Hope this Helps....
Copy linkTweet thisAlerts:
@harevik85authorApr 18.2008 — Thank you veeeeeeeery much, it helped me.
Copy linkTweet thisAlerts:
@Shanu_chaudharyApr 18.2008 — Ok...

But I didn't find a solution for my problem...Can u Help??
Copy linkTweet thisAlerts:
@the-ferretApr 18.2008 — $str = "Hello Annette";

echo "<a href="page2.php?str=".$str.">Hello</a>";

page2.php

..

$srt = $_GET[`str'];

echo "String:".$str;
[/QUOTE]


Have you tried wrapping the string in quotes (remembering to escape them in the php)? Haven't done this for ages as using ajax to save reloading pages but might be worth a try

echo "<a href="page2.php?str="'".$str."">Hello</a>";
Copy linkTweet thisAlerts:
@Shanu_chaudharyApr 18.2008 — The spaces can be cleared by that replace statement...

Can u tel me how to convert javascript variable to php..Is it possible???
×

Success!

Help @harevik85 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.28,
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,
)...