Hi everyone, i need help with this sniplet.
did a lot of modding etc, just can't get my head around resizing the images.
Got them to output successfully.
Please help me in resizing pics?
$height = "100"; //pixels
$width = "100"; //pixels
	
							
						
					did a lot of modding etc, just can't get my head around resizing the images.
Got them to output successfully.
Please help me in resizing pics?
$height = "100"; //pixels
$width = "100"; //pixels
Code:
	
	<?php
include("../includes/connect.php");
/*** some basic sanity checks ***/
if(filter_has_var(INPUT_GET, "image_id") !== false && filter_input(INPUT_GET, 'image_id', FILTER_VALIDATE_INT) !== false)
    {
    /*** assign the image id ***/
    $image_id = filter_input(INPUT_GET, "image_id", FILTER_SANITIZE_NUMBER_INT);
    try     {
        /*** connect to the database ***/
        $dbh = new PDO("mysql:host=".$dbhost.";dbname=".$dbname."", "".$dbuser."", "".$dbpass."");
        /*** set the PDO error mode to exception ***/
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        /*** The sql statement ***/
        $sql = "SELECT image, image_type FROM products WHERE serial=$image_id";
        /*** prepare the sql ***/
        $stmt = $dbh->prepare($sql);
        /*** exceute the query ***/
        $stmt->execute(); 
        /*** set the fetch mode to associative array ***/
        $stmt->setFetchMode(PDO::FETCH_ASSOC);
        /*** set the header for the image ***/
        $array = $stmt->fetch();
        /*** check we have a single image and type ***/
        if(sizeof($array) == 2)
            {
            /*** set the headers and display the image ***/
            header("Content-type: ".$array['image_type']);
            /*** output the image ***/
            echo $array['image'];
            }
        else
            {
            throw new Exception("<img src=\"../images/demo.png\">");
            }
        }
    catch(PDOException $e)
        {
        echo $e->getMessage();
        }
    catch(Exception $e)
        {
        echo $e->getMessage();
        }
        }
  else
        {
        echo '<img src="../images/demo.png">';
        }
?>

Comment