Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,916 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,736 people online right now. Registration is fast and FREE... Join Now!




replacing the %20 with space

 
Reply to this topicStart new topic

replacing the %20 with space

samn84
8 Mar, 2008 - 11:14 PM
Post #1

New D.I.C Head
*

Joined: 21 Feb, 2008
Posts: 41

in my program i pass the values via url in the following manner:

http://......../update.php?name=susan brown&company=tt inc

and when i need to assign this info to variables in php page,i do this:

$name=$_REQUEST['name'];
$company=$_REQUEST['company'];
echo "name: ".$name;
echo "company: ".$company;

in this case the output is as follows:
name: susan
company: tt

and does not print the full names!!!!!
SO the next thing i did to the above code is:

$name=str_replace('%20',' ',$_REQUEST['name'];
$company=str_replace('%20',' ',$_REQUEST['company']);
echo "name: ".$name;
echo "company: ".$company;

but now the output shown is like this:

name: susan%20brown
company: tt%20inc

i also tied this but it doesnt work:
$name=str_replace(' ',' ',$_REQUEST['name'];

any help/suggestion/idea wud be appreciated.



User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Replacing The %20 With Space
8 Mar, 2008 - 11:20 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,998



Thanked: 126 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Use the urldecode function available to you in PHP


php

$name = urldecode($_REQUEST['name']);
$company = urldecode($_REQUEST['company']);
echo "name: ".$name;
echo "company: ".$company;

User is online!Profile CardPM
+Quote Post

no2pencil
RE: Replacing The %20 With Space
8 Mar, 2008 - 11:20 PM
Post #3

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,495



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Try referencing the $_POST value with double quotes, like this:

CODE

$name=$_REQUEST["name"];


QUOTE(PsychoCoder @ 9 Mar, 2008 - 12:20 AM) *

Use the urldecode function available to you in PHP

*Hats of to PsychoCoder for the better solution*
User is online!Profile CardPM
+Quote Post

PsychoCoder
RE: Replacing The %20 With Space
8 Mar, 2008 - 11:29 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,998



Thanked: 126 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Thank ya sir blush.gif
User is online!Profile CardPM
+Quote Post

samn84
RE: Replacing The %20 With Space
8 Mar, 2008 - 11:32 PM
Post #5

New D.I.C Head
*

Joined: 21 Feb, 2008
Posts: 41

does the urldecode function actually put the respective space back in the word like
name :susan brown
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Replacing The %20 With Space
8 Mar, 2008 - 11:49 PM
Post #6

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,998



Thanked: 126 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Why yes sir it does smile.gif
User is online!Profile CardPM
+Quote Post

samn84
RE: Replacing The %20 With Space
8 Mar, 2008 - 11:56 PM
Post #7

New D.I.C Head
*

Joined: 21 Feb, 2008
Posts: 41

fanx m8!!!
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Replacing The %20 With Space
8 Mar, 2008 - 11:58 PM
Post #8

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,998



Thanked: 126 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Anytime, glad I could help smile.gif
User is online!Profile CardPM
+Quote Post

musya
RE: Replacing The %20 With Space
9 Mar, 2008 - 12:34 AM
Post #9

D.I.C Regular
Group Icon

Joined: 25 Apr, 2007
Posts: 291



Thanked: 1 times
Dream Kudos: 50
My Contributions
QUOTE(PsychoCoder @ 9 Mar, 2008 - 12:58 AM) *

Anytime, glad I could help smile.gif


Okay call me a noobie (which I am) but does this hide the url that shows up in the browser when the user opens the page? if not is there a way to do that? for example to hide the big long php queris such as are in this edit page now at the top of the page.
QUOTE

is there a way to hide that too just
QUOTE


???? Any hope here?
User is offlineProfile CardPM
+Quote Post

samn84
RE: Replacing The %20 With Space
9 Mar, 2008 - 01:09 AM
Post #10

New D.I.C Head
*

Joined: 21 Feb, 2008
Posts: 41

yes i wna ask the same question too as to how to hide the querystring bit in the url....................
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Replacing The %20 With Space
9 Mar, 2008 - 01:19 AM
Post #11

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,495



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(samn84 @ 9 Mar, 2008 - 02:09 AM) *

yes i wna ask the same question too as to how to hide the querystring bit in the url....................

On you html FORM, you want to use a method of POST, rather than GET.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:06PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month