Trouble with question mark in URL

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
declan
Forum Newbie
Posts: 1
Joined: Sun Jun 27, 2010 1:14 am

Trouble with question mark in URL

Post by declan »

Hey guys!

I'm having some trouble with something. Right now, the process for submitting and displaying an "article" is roughly this:
1. They enter some text (the article), and a title
2. A script cleans the title, replaces spaces with _'s
3. It names the file the text is kept in the cleaned article name
4. When you go to a page with the articles, it turns the _'s back into spaces to print the link to the article
5. There is also a thumbnail for the article, named <cleaned article name>.jpg

But I'm having a problem when an article's title has a question mark in it. When I look at the thumbnail in my client, it lists it with a question mark. For example: does_this_work?.jpg . And when I go to the directory in my browser, it is labeled the same. But if I click on it and view the picture directly, it has %3f in the url. I know this has something to do with the fact that ? is actually a delimiter in URL's, but I'm trying both ways (having the picture titled with %3f's instead of ?'s) and it's not working.

Can anyone enlighten me? Thanks!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Trouble with question mark in URL

Post by John Cartwright »

Pass your title through urlencode() prior to including it in your url.
Post Reply