danIT Posted May 19, 2009 Posted May 19, 2009 Need a little help, i'm by now means literate in PHP but here goes: $tag=$_GET['tag']; if($_GET['tag']==''){ $tag = 'Search...';} if (!isset($_GET['maxpages'])) { $max_pages = 20; }else { $max_pages = $_GET['maxpages']; } if ($max_pages > 50) { die("No way am i doing more than 50 pages. Sorry mate."); } ?> I use a form to take $tag and stick it on the end of a url: http://search.twitter.com/search.atom?&q={$tag} Its basically a Twitter search script, the trouble i having is if $tag contains a #, kinda vital to a twitter search. I think whats happening is this: $tag = #edugeek - Twitter Search%23edugeek I think twitter needs to get #edugeek not %23edugeek How can I change my script so that if $tag starts with # or contains # it is correctly sent to twitter? To test I replaced %23 to # in the browser and it works, just need the script to do it now!
dwhyte85 Posted May 19, 2009 Posted May 19, 2009 (edited) PHP: urldecode - Manual UrlDecode, this will change %23 to # within your string $tag = urldecode($_GET['tag']);// should work or, $tag = $_GET['tag'];$tag = urldecode($tag); if($_GET['tag']==''){ $tag = 'Search...';} if (!isset($_GET['maxpages'])) { $max_pages = 20; }else { $max_pages = $_GET['maxpages']; } if ($max_pages > 50) { die("No way am i doing more than 50 pages. Sorry mate."); } ?> Edited May 19, 2009 by dwhyte85
danIT Posted May 19, 2009 Author Posted May 19, 2009 Superb, thats exactly what I needed.... Well almost, I got the problem wrong... I needed to Encode the # not decode Ta!
powdarrmonkey Posted May 19, 2009 Posted May 19, 2009 Superb, thats exactly what I needed.... Well almost, I got the problem wrong... I needed to Encode the # not decode Ta! That'll be PHP: urlencode - Manual then...
danIT Posted May 19, 2009 Author Posted May 19, 2009 -- Sidenote: I also generate a .csv of the search to download, anyone know how I might store this on the server once generated? A colleage did tell me the name of a function but cant for the life of me remember? Think it began with S?
powdarrmonkey Posted May 19, 2009 Posted May 19, 2009 Sidenote: I also generate a .csv of the search to download, anyone know how I might store this on the server once generated? A colleage did tell me the name of a function but cant for the life of me remember? Think it began with S? Probably fopen(), fwrite() and fclose().
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now