SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to rotate image fetching dynamically from database?

    Hi all,
    I want to display an image with 180 degrees (rotate) an image in my web page, that to getting the image URL from database dynamically, based on select box selection.

    But i used the link like this:::
    getting $id from select box.
    PHP Code:
    $imgFile=imagerotate('images/'.$id.'.gif'1800); 
    then it will shows an error like this:
    Warning: imagerotate() expects parameter 1 to be resource, string given.

    how to use this function? can any one help regarding this.....

    Note::
    in same page i want to display another select box and another image as well without any disturbance in the other images.

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,398
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I would first try changing the ' to "
    PHP Code:
     $imgFile=imagerotate("images/".$id.".gif"1800);
    //This may work and be better:
     
    $imgFile=imagerotate("images/$id.gif"1800); 
    Then I would try conenating? the name outside the function:
    PHP Code:
    $image =  "images/$id.gif"
    $imgFile=imagerotate('$image, 180, 0); 

  3. #3
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $image = "images/$id.gif";

    $imgFile=imagerotate($image, 180, 0);

    I used like that.
    but the same error it is showing on this line.::Warning: imagerotate() expects parameter 1 to be resource, string given
    $imgFile=imagerotate($image, 180, 0);

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Check the manual page for examples, you need to create an image resource first.
    PHP Code:
    <?php
    $image 
    imagecreatefromgif('path/to/image.gif');
    $rotated imagerotate($image1800);
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

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