($_GET['n']);

Discussion in 'PHP' started by Elfminster, Jul 31, 2009.

  1. #1
    Howdy.

    I need a little help. :)

    I have an index.php page with a .jpg. When you click the image, you go to a new page with the same image. It works fine.

    index.php Code

    <a href="http://www.domain.com/view.php?n=an_image.jpg</a
    Code (markup):
    view.php Code

    <?php
    include("header.php");
    $pic = ($_GET['n']);
    echo '<img src="' . $pic. '" />';
    include("footer.php");
    ?>
    
    Code (markup):
    The problem is I want to include an image resizer (http://shiftingpixel.com/2008/03/03/smart-image-resizer/) and resize the image on the new page automatically. I have no idea how to do this.

    The code for the resizer is:-

    <img src="/image.php/coffee-bean.jpg?width=150&amp;height=150&amp;cropratio=1:1&amp;image=/wp-content/uploads/2008/03/coffee-bean.jpg" alt="Coffee Bean" />
    Code (markup):
    I tried this:

    <a href="http://www.domain.co/view.php?n=/image.php/new_image.jpg?width=150&amp;height=150&amp;cropratio=1:1&amp;image=an_image.jpg</a
    Code (markup):
    I also tried putting it in the view.php.

    echo '<img src="image.php' . $pic. '?width=659&amp;height=1200&amp;image=/" />';
    Code (markup):
    Any ideas? :)
     
    Elfminster, Jul 31, 2009 IP
  2. Elfminster

    Elfminster Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nevermind. I solved it.

    <img src="http://www.domain.com/image.php<?php echo $_GET['n']; ?>?width=300&amp;height=300&amp;image=<?php echo $_GET['n']; ?>"/>
    Code (markup):
    :D
     
    Elfminster, Jul 31, 2009 IP
  3. Leron

    Leron Active Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    53
    #3
    You should also replace the &amp; with "&" in your url string
    Glad you got it solved:D
     
    Leron, Jul 31, 2009 IP
  4. bbosh

    bbosh Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You should also check out htmlspecialchars().
     
    bbosh, Aug 1, 2009 IP
  5. Elfminster

    Elfminster Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Okay, why change to &? :)

    And do you mean
    $pic = htmlspecialchars($_GET['n']);
    Code (markup):
     
    Elfminster, Aug 1, 2009 IP