Current location: Hot Scripts Forums » Programming Languages » PHP » Trimming information off address


Trimming information off address

Reply
  #1 (permalink)  
Old 11-02-03, 01:49 AM
dr00bie dr00bie is offline
New Member
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Trimming information off address

Hello all,

I'm really new to PHP (although I do have experience in ASP) and I am working on a Picture Gallery and I used the Basic Photo Album (BPA) script to do so, now I am trying to modify the script to my liking. I have the following problems: I need to find a way to trim some info off the address,

for example,

http://drewtestsite.wytheville.com/a....jpg&bg=FFFFFF

I need to get the Vintage (which is a dir.) out of the address...

here is my code as it stands

$includedir = trim($_GET["image"]);
$incdir = $_SESSION['incfolder'];
include "./albums/$incdir/vars.php";
echo "<html>";
echo "<title>$wr_title</TITLE>";
echo "<head></head>";

--The session code is there in an attempt to grab the folder info and session it for use later.

the problem is that $includedir is actually "Vintage/RRR=06.jpg&bg=FFFFFF" instead of just "Vintage"

I need it to just be what is in the address, any help would be appreciated.

Also, is there any way that I can include captions for each picture? The only way I can think of doing that is with a database. Does anyone have any other options?

Thanks,
Drew Laing

To see the error I am recieving, goto http://drewtestsite.wytheville.com/a...folder=Vintage
and click on a thumb.

Last edited by dr00bie; 11-02-03 at 01:52 AM.
Reply With Quote
  #2 (permalink)  
Old 11-02-03, 07:06 PM
evo4ever evo4ever is offline
Software Developer Guru
 
Join Date: Aug 2003
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Hi. Ok, use this line of code to extract the "Vintage" word from the image GET variable:

PHP Code:

$includedir substr($_GET["image"], 07); // Resolves to: $includedir = "Vintage" 

If you will be getting different directories other than "Vintage" then give me a shout, ill make a regex for you.

Reply With Quote
  #3 (permalink)  
Old 11-03-03, 03:42 PM
dr00bie dr00bie is offline
New Member
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you very much, it worked like a charm!

Thanks,
Drew Laing
Reply With Quote
  #4 (permalink)  
Old 11-03-03, 04:13 PM
dr00bie dr00bie is offline
New Member
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Actually, I lied. It didn't work, it only works if the directory is 7 characters long, I didn't notice until I tried it with a different directory. Is there any way to use the same code:

$includedir = substr($_GET["image"], 0, 7); // Resolves to: $includedir = "Vintage"

but instead of the first 7 characters, it trims the variable until before the /.

view.php?image=Vintage/1.jpg&bg=FFFFFF

See the image=Vintage could be image=02032003 or something like that, but it will always have the / after the dir name, therefore if there is a way to take from 0 - the character before /

I dunno, it works out in my mind, but i don't know how to go about it...

Thanks,
Drew Laing
Reply With Quote
  #5 (permalink)  
Old 11-03-03, 05:32 PM
evo4ever evo4ever is offline
Software Developer Guru
 
Join Date: Aug 2003
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Thats no problem. We can use the slash as a deliminator to split the string. Use this code:

PHP Code:

$get_dir split("/"$_GET["image"]);

$includedir $get_dir[0];
unset(
$get_dir[1]); // Discard the right hand side of the slash becuase it isnt needed. 

Last edited by evo4ever; 11-03-03 at 05:35 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP get information from amazon script? gevork ASP 1 10-14-03 02:36 AM
Double-checking an e-mail address in a form Funky Monk JavaScript 2 09-17-03 10:11 PM
Just learning: how do I update information in table? paulj000 PHP 3 08-07-03 10:49 AM
Help Transfering information praeclarus PHP 1 07-24-03 06:03 PM
script to grab any information ? xgab PHP 5 06-22-03 10:33 AM


All times are GMT -5. The time now is 07:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.