[solved] easy question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

[solved] easy question

Post by Illusionist »

Hey, im a little brain dead, and im nto really int he mood to be searching through this big book on how to do this: anways, i have a script taht when someone view my page it takes int heir anem and such, but if there is a space in their name it wont add... hmm... wonder why? i tried stripslahes() and trim() but nothing seems to work.. Any ideas?!
Last edited by Illusionist on Fri Feb 20, 2004 6:19 pm, edited 2 times in total.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

i found that it is because the URL contains the spaces... but there isn't anything i can do about that... because i'm getting the name from somewehre else and have no control over how it is formated before it gets passed through my page....
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

Code: Select all

<?php
$name = $_GET['name'];
$name = str_replace(" ", "_",$name);
?>
put that on the top of page where you want to add the name to db or whatever, it will replace spaces with underscore, when u need to display it just replace underscore with space :D.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

thansk bud, but that doesn't work!!! the GET stops at the first space it comes to... so if the name was like Bob Marley, it will only get Bob
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Anyone else got any ideas that might help?!?!?!?!?!?!?!?!?!?!?!?!
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

What is the output if you use this?

Code: Select all

<?php
echo $_SERVER['REQUEST_URI'] . "<br />";
echo $_SERVER['QUERY_STRING'];
echo "<pre>";
print_r($_GET);
echo "</pre>";
?>
You might be able to use one of those to get the name. I don't know why your script isn't working. When I tested it on my server it kept adding "%20" in between the two parts of my name. (In case you didn't know, %20 = blankspace).
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

ya i know %20 is a blankspace... this si what i get:

Code: Select all

/profile/?sn=encryptedsn=encryptedArray
(
    &#1111;sn] => encrypted
)
and the screename is encrypted bug

it always messes up with there is a space int eh screenname
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

hmm.... if i type it into the url, i get teh ocrrect result:

Code: Select all

/profile/?sn=encrypted%20%20bug
sn=encrypted%20%20bug

Array
(
    &#1111;sn] => encrypted  bug
)
but the other way is comming from a link in the AIM profile window and im using %n to get teh screenname, but it still shows the screenname as encrypted bug, but the page doesn't get it....
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

*BUMP*

anyone got any ideas? It seems as if a name is passed in through a link with spaces in it, the $_GET['name'] will not work... it only gets the first part until it reaches the first space... Anyone got ANY other ideas on how i can get the full string after name= ??

Thanks
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Do you have any control over how the name is being passed?

If so, use urlencode() on the name before passing it over.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Illusionist wrote:i found that it is because the URL contains the spaces... but there isn't anything i can do about that... because i'm getting the name from somewehre else and have no control over how it is formated before it gets passed through my page....
no i dont... What im doing is making sub-profiles for my friends like buddyprofile.com... But the only thing i can't get over now is that when a s/n with spaces clicks teh link it only GETS teh first part of the name fromt he URL. If you know anyone that has a profile hosted by buddyprofile.com, and you have AIM format your s/na nd put a few spaces in it, and then look at their profile. before you click the sub-profile link, look at the URL it has your name at the end witht he spaces, but once you click through if the person has it setup to show the person's name then it will have your name there, wiht no spaces... If not then look at the links for soem of the other pages, they should also have your name int here without the spaces.... How did they format it so that it removes the spaces?! because i haven't even been succesful in retrieve the second part of a name!

Thanks for the help
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

someone's gotta know something!!! come on experts help me out :)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

The passed value has to have no spaces, or be urlencoded (or rawurlencoded) .. that's pretty much it.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Maybe AIM removes it for you?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

BUMP
Post Reply