I've managed to get an image resizing tool running on my site, but it only works with images when the URL of the image is hardcoded into the page. As soon as I try and get the image path from a database, the code outputs a load of gibberish.
<?php
include ('/www/business/7445a/includes/globals.php');
$image_id = $_GET['image_id'];
$result = mysql_query("SELECT news_image FROM tbl_news WHERE news_id = '$image_id'"); // Gets the image file name from DB.
while ($row = mysql_fetch_array($result)){
$image = "http://www.theipp.co.uk/images/news/".$row['news_image']."";
$im = @imagecreatefromjpeg($image); // Changes the image from a file path to an image resource.
$type = @getimagesize($image);
$height = imagesy($im);
$width = imagesx($im);
$imgw = 120; // Sets the width of the thumbnail
$imgh = $height / $width * $imgw;
$thumb = @imagecreatetruecolor($imgw,$imgh); // Creates blank thumbnail
@imagecopyresized($thumb, $im, 0, 0, 0, 0, $imgw, $imgh, $height, $width); // Copies main image into thumbnail.
// Displays the resized image
@header("Content-type: {$type['mime']}");
@imagejpeg($thumb);
}
?>
This code works perfectly when $image is set without the SQL statement but not with. As soon as the globals file is included it out puts
"ׇ¨cÁÍ]T_z;1$ÙÊÝÉøªÿ�…ZK¶Æ"
Any ideas? This is driving me insane.