Page 1 of 1

Problem with url variable passing..

Posted: Fri Jul 24, 2009 6:22 am
by johniem
I want to pass some variables with GET method through url.Everything seems ok and working fine but with a small problem that i can't figgure out..

The one variable passes a value that it's in greek.. When user clicks the link to open the page the greek text appears ok on the page. But when he wants to refresh the page and insteed of clicking on the reload browser button or hitting the "F5" key, chooses to just press enter on the address box then the greek text looses its encoding and appears with "?" on the page and in the url the greek text changed to "%CC%CF%C4%C1". Here is the url as it appears on the address bar.

mainCategories.php?category=%CC%CF%C4%C1&categoryId=FASHION

I have set

Code: Select all

header('Content-Type: text/html; charset=utf-8');


in my php script and the file.php is in UTF8 mode..

any ideas how can i fix this??

Re: Problem with url variable passing..

Posted: Fri Jul 24, 2009 6:47 am
by UnknownOne
Not sure you can have greek text in the url.

Visit

Code: Select all

http://www.w3schools.com/tags/ref_ascii.asp
for more info. You may be able to use ascii format.

OR you can check here, even better. Greek chars as well.

Code: Select all

http://www.w3schools.com/tags/ref_symbols.asp

Re: Problem with url variable passing..

Posted: Fri Jul 24, 2009 1:35 pm
by johniem
The thing is that the greek chars are passing to the other page normally without problem,and when i'm printing them everything is fine...When the user just refreshes the page by hitting the enter key on the address bar (and only at that case) the characters loosing the encoding...

I know that i can have greek text on the url, but why this happenning at that case only??

Re: Problem with url variable passing..

Posted: Sat Jul 25, 2009 9:06 am
by cpetercarter
You cannot use Greek characters directly in a url. You need to url_encode them first.

Re: Problem with url variable passing..

Posted: Sat Jul 25, 2009 9:07 am
by johniem
But why it's working in the normal flow??

Re: Problem with url variable passing..

Posted: Sat Jul 25, 2009 10:07 am
by Eric!
Depends on what the normal flow is. Is the client browser actually submitting this URL or are you just posting the url data to other scripts on the server? If the client submits the URL without it encoded properly the server might barf. I suppose it would depend on how the server API handles passing between scripts vs client-server submissions. I'm not sure of the details there....

Re: Problem with url variable passing..

Posted: Sat Jul 25, 2009 10:19 am
by cpetercarter
The Greek characters seem to display OK in the browser address bar. All this means, however, is that your browser is a forgiving thing which lets you get away with unencoded urls. The problem is at the other end, at the server. What will it make of an unencoded url? It may return garbage characters; or it may say that it cannot find the requested URL.

Re: Problem with url variable passing..

Posted: Sat Jul 25, 2009 12:39 pm
by johniem
Well, browsers are all english versions and the url is created by a script and delivered to the client.So, the client has already the url at his side and when he clicks on the link that has that url the server gets the url and making the page that client has requested. At this flow the greek characters appears as they should, both in url and in the page..Anyway, i didn't know the urlencode() method and i'm going to use it cause it's the propper way to do it. :)