Problem with url variable passing..

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

Post Reply
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

Problem with url variable passing..

Post 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??
UnknownOne
Forum Newbie
Posts: 5
Joined: Thu Jul 23, 2009 8:52 am

Re: Problem with url variable passing..

Post 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
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

Re: Problem with url variable passing..

Post 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??
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Problem with url variable passing..

Post by cpetercarter »

You cannot use Greek characters directly in a url. You need to url_encode them first.
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

Re: Problem with url variable passing..

Post by johniem »

But why it's working in the normal flow??
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Problem with url variable passing..

Post 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....
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Problem with url variable passing..

Post 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.
johniem
Forum Commoner
Posts: 29
Joined: Mon Jul 20, 2009 8:58 am

Re: Problem with url variable passing..

Post 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. :)
Post Reply