Multiple words in query string

Hi all

I am using a single php file to display a table of data but different database tables and fields may be used depending on criteria values passed in the query string.

It all works fine but I need to pass a multiple word value that represents the caption for the table e.g. “Computer Training”

PHP only takes the characters up until the first space.

I understand why but is there any way around this problem?

I could set up a session variable but it will change every time the page is called and not a good use of this technique.

Any ideas appreciated.


Assuming your passing the variable via a direct url (eg ?word=Computer Training) then chainey is on the right track with this. You need to replace the space with %20 (the urlencoded version of a space).

If you’re typing the words into a text box in a form on your html page and using get the browser should be doing this automatically. Post won’t be affected.

Can you show us your code please?

Thanks tangoforce

I have used urlencode and it works fine.

It is interesting to note that I do not need to use urldecode to decode it.

I posted a problem, went to bed late, got up and there was a solution. That is what I love about forums and time zones.

Thanks again.