Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    123
    Thanks
    20
    Thanked 1 Time in 1 Post

    Including an image with GET function

    Hi,
    I am trying to include an image using the get function. Script:

    PHP Code:
    <?php include ('tutors/$_GET["tutor"]'.'jpg'); ?>
    The file which the script is in, is in the root (/) and the images are in a directory in the root called "tutors". The webaddress is then something like
    Code:
    www.mydomain.com/?tutor=LS
    The image in the "tutors" folder is called LS.jpg.
    Thanks

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    I don't think you 'include' an image - wherever you want it, just put

    <img src="tutors/<?php print $_GET['image']; ?>.jpg" />

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    New Coder
    Join Date
    Jun 2007
    Location
    VA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    take a look at this function:

    http://us.php.net/manual/en/function.imagejpeg.php

    I haven't tried it yet, but that's because I use HTML to render the image

  • #4
    Regular Coder
    Join Date
    Jan 2007
    Posts
    123
    Thanks
    20
    Thanked 1 Time in 1 Post
    Quote Originally Posted by ddanatzko View Post
    take a look at this function:

    http://us.php.net/manual/en/function.imagejpeg.php

    I haven't tried it yet, but that's because I use HTML to render the image
    How do you do it in html?

  • #5
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    See my above post

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #6
    New Coder
    Join Date
    Jun 2007
    Location
    VA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Check Whizard's post, he's got it for you:

    Quote Originally Posted by whizard View Post
    I don't think you 'include' an image - wherever you want it, just put

    <img src="tutors/<?php print $_GET['image']; ?>.jpg" />

    HTH
    Dan

  • #7
    Regular Coder
    Join Date
    Jan 2007
    Posts
    123
    Thanks
    20
    Thanked 1 Time in 1 Post
    I can't seem to get that to work.

  • #8
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    In what way - what kind of problem are you having?

    I'm not psychic

    Also, show us the applicable code... for the same reason

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #9
    Regular Coder
    Join Date
    Jan 2007
    Posts
    123
    Thanks
    20
    Thanked 1 Time in 1 Post
    Cancel that. Forgot to clear the cache. Sorry. Thanks

  • #10
    New Coder
    Join Date
    Jun 2007
    Location
    VA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $_GET is a superglobal array used for containing information passed to the script. Are you referencing an image that was uploaded to the page? If so, you can use the copy() function before referencing the file and then reference the file name and location in the img src="<? echo $file; ?>:


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •