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!

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.

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.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.