Create query from my function

okay i cant figure this out. i have a function that resizes my image when i upload it and puts it into a seperate folder. i then need to get the path of the file and write that to my database.

this is my function:

<?php

function thumbnail($image, $maxWidth, $maxHeight) {    
    $pinfo = pathinfo($image);
    $tmb_name = $pinfo['dirname'].'/thumbs/'.$pinfo['filename'].'_tmb.'.$pinfo['extension'];
    $quality = 100; // imagejpeg() accepts quality as the third variable, not a path.

    switch($pinfo['extension']) :
        case "jpg" :
        case "jpeg" : 
            $fileType = "jpeg";
            $imageCreateFunction = "imagecreatefromjpeg";
            $imageOutputFunction = "imagejpeg";
        break;
        case "png" :
            $fileType = "png";
            $imageCreateFunction = "imagecreatefrompng";
            $imageOutputFunction = "imagepng";
        break;
        case "gif" :
            $fileType = "gif";
            $imageCreateFunction = "imagecreatefromgif";
            $imageOutputFunction = "imagegif";
        break;
    endswitch;

    list($originalWidth, $originalHeight) = getimagesize($image);
    $x_ratio = $maxWidth / $originalWidth;
    $y_ratio = $maxHeight / $originalHeight;
    // check that the new width and height aren't bigger than the original values.
    // the new values are higher than the original, don't resize or we'll lose quality
    if (($originalWidth <= $maxWidth) && ($originalHeight <= $maxHeight)) {
        $newWidth = $originalWidth;
        $newHeight = $originalHeight;
    } else if (($x_ratio * $originalHeight) < $maxHeight) {
        $newHeight = ceil($x_ratio * $originalHeight);
        $newWidth = $maxWidth;
    } else {
        $newWidth = ceil($y_ratio * $originalWidth);
        $newHeight = $maxHeight;
    }

    $src = $imageCreateFunction($image);
    $dst = imagecreatetruecolor($newWidth, $newHeight);
    // Resample
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
    // Save image
    $imageOutputFunction($dst, $tmb_name, $quality);
    imagedestroy($src);
    imagedestroy($dst);
    return true;
}

?>

this is me using the function:

$image = $target_path;
                        $maxHeight = 90; $maxWidth = 150;
                        include 'thumbnail_function.php'; // Include the function file
                        thumbnail($image, $maxWidth, $maxHeight);

and then i thought the query would be this:

$thumb_path = $dbLink-&gt;real_escape_string($tmb_name);
          
          //query to insert the data i had gathered into the database
          $query = "INSERT INTO `images` (`name`, `size`, `created`, `image_path`, `gallery_type_id`, `desc`, `thumbnail_path`)
             VALUES ('{$name}', {$size}, NOW(), '{$image_path}', '{$gallery_type}', '{$desc}', '{$thumb_path}')";

i dont know how to take the variable tmb_name in my function and use it in my other file so i can do the query to store the image path

You don’t have to, since you know how you constructed that variable:

$pinfo = pathinfo($image); 
$tmb_name = $pinfo['dirname'].'/thumbs/'.$pinfo['filename'].'_tmb.'.$pinfo['extension'];
$thumb_path = $dbLink->real_escape_string($tmb_name);