Jump to content

%20 Percent Sign / Space Causing Problems with PHP


member123

Recommended Posts

I use a feed reader called Feed on Feeds that uses PHP/MySQL.  It has a feature that lets you define some words to automatically tag, and if a new post comes in with those words in it, they get tagged.

 

I have several words set up, including some that are multiple words (e.g. Steve Jobs).  They get tagged fine.  When I check in the database, the articles include those tags.

 

When you sort by tag in the reader, it goes to a URL like this: http://www.domain.com/?what=Apple and then a GET function takes the Apple and displays all articles with that tag.  When you sort by a tag that is multiple words, you get something like http://www.domain.com/?what=Steve%20Jobs.

 

That doesn't load any of the tags, possibly because of the %20 conversion.

 

I've tried going into the function where this appears:

 

if(!isset($_GET['what']))

{

    $what = "unread";

}

else

{

    $what = $_GET['what'];

}

 

and replacing it with:

 

if(!isset($_GET['what']))

{

    $what = "unread";

}

else

{

    $what = urldecode($_GET['what']);

}

 

but unfortunately that didn't solve the problem.

 

I also tried changing it to this, just to get a better idea of what was causing the problem:

if(!isset($_GET['what']))

{

    $what = "unread";

}

else

{

    $what = "Steve Jobs";

}

 

When it was changed to that, clicking on any tag, even a one-word tag, should bring up all of the articles that are tagged "Steve Jobs".

 

Anybody know what is going wrong, or if I am making a stupid mistake or something?

 

Thanks!

Link to comment
Share on other sites

str_replace('%20', ' ', $_GET['what'])

 

?

 

Hi Looie, that was actually one of the first things I tried.  I had an if statement check of the tag contains a %20, and then I used your code to replace the %20 with a space.  Unfortunately, it didn't work.  The problem seems to be somewhere else in the code.  Even when I hard code the space, I can't sort by tags with spaces in them.

Link to comment
Share on other sites

After you urldecode it, echo it out and make sure it's a space.  Then I'll try to help from there.  For free.  (I only saw the topic now, otherwise I would have helped earlier.  I don't think you should have to pay for someone to offer their knowledge and help you better your skills.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.