hi all, im looking to resize an image from the following code,

but i keep getting errors when trying to resize the image inline.

<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['img1'] . '<br>' . $row['datetime'] . '<br>' . $row['message_title'] . '</a><font face="Verdana, Arial, Helvetica, sans-serif" size="1">&nbsp;(You have mail)</font><br><br>

any pointers would be appreciated

hi all, im looking to resize an image from the following code,

but i keep getting errors when trying to resize the image inline.

<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['img1'] . '<br>' . $row['datetime'] . '<br>' . $row['message_title'] . '</a><font face="Verdana, Arial, Helvetica, sans-serif" size="1">&nbsp;(You have mail)</font><br><br>

any pointers would be appreciated

Whoops... Are you trying to send a complete image here? In theory you can send an endless number of bytes this way, but for instance a Microsoft web server will only accept 2048 bytes in total.
To me it seems a lot better to POST everything. Like so:

<?php
echo "<form method=\"post\" action=\"read_message.php\">
<input type=\"hidden\" name=\"message_id\" value=\"".$row['message_id']."\"/>
<input type=\"hidden\" name=\"image\" value=\"".$row['img1']."\"/>
<input type=\"hidden\" name=\"datetime\" value=\"".$row['datetime']."\"/>
<input type=\"hidden\" name=\"title\" value=\"".$row['message_title']."\"/>
<input type=\"sumbit\"  value=\"you have mail\"/>
</form>";
?>

And use $_POST to get the variables in "read_message.php".

Whoops... Are you trying to send a complete image here? In theory you can send an endless number of bytes this way, but for instance a Microsoft web server will only accept 2048 bytes in total.
To me it seems a lot better to POST everything. Like so:

<?php
echo "<form method=\"post\" action=\"read_message.php\">
<input type=\"hidden\" name=\"message_id\" value=\"".$row['message_id']."\"/>
<input type=\"hidden\" name=\"image\" value=\"".$row['img1']."\"/>
<input type=\"hidden\" name=\"datetime\" value=\"".$row['datetime']."\"/>
<input type=\"hidden\" name=\"title\" value=\"".$row['message_title']."\"/>
<input type=\"sumbit\"  value=\"you have mail\"/>
</form>";
?>

And use $_POST to get the variables in "read_message.php".

___________________
Hi thanks for the quick reply, even with your code the image still needs to be resized,

Im looking into echo-ing a table out. i just need to decide the layout, but the main object is being able to resize the image

I wrote the following code for a photobook project a few months ago. It will re-size a jpeg image to 140px width or 140px height (see $new_w and $new_h). But the image needs to be on the server in a folder first. $source could be something like "/images/demoimage.jpg" and $dest writes it back to a folder (like "/images/thumbs/demoimage.jpg").
It is not quit what you need, but maybe it will give you enough inside to see how to re-size an image.

function imgthumb($source, $dest) {
	$new_w = 140;
	$new_h = 140;
	$have_img = FALSE;
	// Check if file is a jpeg image and calculate with * height
	if (filesize($source) > 11) {
		$imagetype = exif_imagetype($source);
		if ($imagetype == 2) {
			// $source is a jpg image - create image from source image
			$src_img=imagecreatefromjpeg($source);
			$have_img = TRUE;

			// Find original size
			$old_x=imagesx($src_img);
			$old_y=imagesy($src_img);

			if ($old_x > $old_y) {
				$thumb_w = $new_w;
				$thumb_h = $old_y * ($new_h / $old_x);
			}
			if ($old_x < $old_y) {
				$thumb_w = $old_x * ($new_w / $old_y);
				$thumb_h = $new_h;
			}
			if ($old_x == $old_y) {
				$thumb_w = $new_w;
				$thumb_h = $new_h;
			}
		}
	}
	
	if ($have_img) {
			$dst_img = imagecreatetruecolor($thumb_w,$new_h+5); // Create new image for thumb
			$border_color = imagecolorallocate($dst_img, 255, 255, 255);
			imagefilledrectangle($dst_img,0,0,$thumb_w,$new_h+5,$border_color);
			// Copy resized on to new canvas
			imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
	}
	else {
			$dst_img = imagecreatetruecolor($new_w,$new_h+5); // Create new image for thumb
			$border_color = imagecolorallocate($dst_img, 255, 255, 255);
			imagefilledrectangle($dst_img,0,0,$new_w,$new_h+5,$border_color);
	}

	imagejpeg($dst_img,$dest); // Output thumb

	// Destroy image data
	imagedestroy($dst_img);
	if ($have_img) {imagedestroy($src_img);}
}

Forgot to tell, if the source file is not a jpeg a blank jpg will be created.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.