biggerboy Posted October 24, 2007 Share Posted October 24, 2007 I am using the code below to generate my new image, however instead of showing the image it just shows the url that I am using. What is wrong with my syntax? Thanks, Alex // Lets make sure the id is safe $id = $_GET['id']; $id = sql_sant($id); $query = "SELECT * FROM images WHERE id= '$id'"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result) == 0) { $errormsg = 'Invalid ID, redirecting you back to homepage<br /> You will be redirected in 5 seconds, if you are not redirected <a href =" . $url . "> click here </a>'; header('Refresh: 5; url= index.php '); exit(); } $line = mysql_fetch_array($result, MYSQL_ASSOC); $filename = $line['realname']; $filetype = $line['type']; $getfile = './imgs/' . $filename; // Lets get the image to fit into our page $width = 600; $height = 600; list($origwidth, $origheight) = getimagesize($getfile); if ($width && ($width_orig < $origheight)) { $width = ($height / $origheight) * $origwidth; } else { $height = ($width / $origwidth) * $origheight; } $imagef = imagecreatetruecolor($width,$height); if ($filetype == 'image/bmp') { $thumb = imagecreatefromwbmp($getfile); } if ($filetype == 'image/gif') { $thumb = imagecreatefromgif($getfile); } if ($filetype == 'image/png') { $thumb = imagecreatefrompng($getfile); } if ($filetype == 'image/jpeg') { $thumb = imagecreatefromjpeg($getfile); } // ALMOST done Just put these babies where they need to be imagecopyresampled($imagef, $thumb, 0, 0, 0, 0, $width, $height, $origwidth, $origheight); if ($filetype == 'image/wbmp') { header('Content-type: image/vnd.wap.wbmp'); imagewbmp($imagef); } if ($filetype == 'image/jpeg') { header('Content-type: image/jpeg'); imagejpeg($imagef); } if ($filetype == 'image/png') { header('Content-type: image/png'); imagepng($imagef); } if ($filetype == 'image/gif') { header('Content-type: image/gif'); imagegif($imagef); } Quote Link to comment https://forums.phpfreaks.com/topic/74536-imagecopyresampled-problem/ Share on other sites More sharing options...
atlanta Posted October 24, 2007 Share Posted October 24, 2007 add the rest of the file so we see all the code some variables that are called arent showing in the code you posted Quote Link to comment https://forums.phpfreaks.com/topic/74536-imagecopyresampled-problem/#findComment-376742 Share on other sites More sharing options...
biggerboy Posted October 24, 2007 Author Share Posted October 24, 2007 Added full code. Quote Link to comment https://forums.phpfreaks.com/topic/74536-imagecopyresampled-problem/#findComment-376745 Share on other sites More sharing options...
atlanta Posted October 24, 2007 Share Posted October 24, 2007 hey ok i got the code edit to where it works can you send me the url where u have the error i want to see what error you get Quote Link to comment https://forums.phpfreaks.com/topic/74536-imagecopyresampled-problem/#findComment-376749 Share on other sites More sharing options...
biggerboy Posted October 24, 2007 Author Share Posted October 24, 2007 Anyone else see anything? Quote Link to comment https://forums.phpfreaks.com/topic/74536-imagecopyresampled-problem/#findComment-377248 Share on other sites More sharing options...
atlanta Posted October 24, 2007 Share Posted October 24, 2007 the only thing is to check to make sure that the values coming from the DB of the match the values that are put into the if statements .. i took out the db function and made mine static and go the script to work fine so hit me up in a PM if u need help on it Quote Link to comment https://forums.phpfreaks.com/topic/74536-imagecopyresampled-problem/#findComment-377332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.