Trouble rotating image

i can’t get the read_exif_blablab whatever to work so i created a entry in the database to inform the page of the orientation of the image, if the value is one then the image needs to be rotated 90 degrees, well i got it to work when i declare the image name as plain text but when i try to get it to read it in a variable all hell breaks loose image turns into a text nightmare. is their a way to get this to work? here is the source code

        echo '<img src='.'"'.$temp[2].'"'.">";
        $image = $temp[1];

//How many degrees you wish to rotate
$degrees = 90;
// Create the canvas
$source = imagecreatefromjpeg("italy/".$image) ;

// Rotates the image
$rotate = imagerotate($source, $degrees, 0) ;

// Outputs a jpg image, you could change this to gif or png if needed
imagejpeg($rotate) ;