Why doesn't variables work in image strings?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajm113
    New Member
    • Jun 2007
    • 161

    Why doesn't variables work in image strings?

    I want to create a image string that retrieves the params of the url to put on the image in php like so:

    image.php?user= Ajm113

    Then it should print the user on the image string, but for some reason it doesn't work. Is it more then that?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    you need to $_GET['user'] to use the string.

    Comment

    • nashruddin
      New Member
      • Jun 2008
      • 25

      #3
      Try this:

      Code:
      <?php
      $text = $_GET['user'];
      
      $im = imagecreate(100, 20);
      $bg = imagecolorallocate($im, 200, 200, 200);
      $fg = imagecolorallocate($im, 0, 0, 255);
      
      imagestring($im, 3, 5, 3, $text, $fg);
      
      header("Content-type: image/png");
      imagepng($im);
      ?>
      call the script with something like image.php?user= myusername

      Comment

      Working...