URL 'n' Image

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
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

URL 'n' Image

Post by Dale »

Instead of me writing the address to the images and making 259 sepaate pages for these images is it possible to have this:

When your URL is:
http://www.cheese.com/gallery/index.php?img=01

Your IMAGE tag changes to:
http://www.cheese.com/gallery/dale/image01.jpg


Your kinda code:
http://www.cheese.com/gallery/dale/image$img.jpg

Is it possible and if it isnt then could you please correct it :)
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Re: URL 'n' Image

Post by jason »

Dale wrote:Instead of me writing the address to the images and making 259 sepaate pages for these images is it possible to have this:

When your URL is:
http://www.cheese.com/gallery/index.php?img=01

Your IMAGE tag changes to:
http://www.cheese.com/gallery/dale/image01.jpg


Your kinda code:
http://www.cheese.com/gallery/dale/image$img.jpg

Is it possible and if it isnt then could you please correct it :)
image.php

Code: Select all

<img src="dale/image<?=$_GETї'img']?>.jpg" />
Of course, that doesn't include things like checking the input, making sure the file exists, etc, but should get you stared.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

ok my picture thing works but also if i add a .TXT file into the same directory as the image and name the image image01.jpg and the text file image01.txt can i include:

Code: Select all

<?=$_GETї'img']?>
Inside a include tag?
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

I've tried this:

Code: Select all

<img src= "./dale/image<?=$_GETї'img']?>.jpg"><br><br>
<?PHP 
include("image<?=$_GETї'img']?>.txt");
?>
But that dont work :(

I get this:

Code: Select all

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/local/etc/httpd/dale.unrealism.com/gallery/index.php on line 10
Any ideas?
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Try this to include the text file:-

Code: Select all

<img src= "./dale/image<?=$_GETї'img']?>.jpg"><br><br> 
<?php  
include("image{$_GETї'img']}.txt");
?>
If you want to print the content of the txt file use:-

Code: Select all

<img src= "./dale/image<?=$_GETї'img']?>.jpg"><br><br>
<?php
  $fh = fopen("image{$_GETї'img']}.txt","r");
  $content = fread($fh,filesize("image{$_GETї'img']}.txt"));
  echo $content;
  fclose($fh);
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Takuma if i had the transport to goto Derby... i would kiss you (NOTE: Im not gay) because you've fixed another one of my problems...
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Whatever you do just don't kiss me :wink:
Just hug me :lol:
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Image
Post Reply