Horrible formatting - no wonder you're comprehension is off. Let's see if I can understand it better if I tidied it
up:
if(isset($_POST['continue']))
{
if(isset($_FILES['picture']))
{
$src_img = $_FILES['picture'];
$name = $_FILES['picture']['name'];
require_once ('./mysql_connect.php');
$query = "SELECT obit_id FROM obituary ORDER BY obit_id DESC LIMIT 1";
$result = @mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_NUM);
$obit_id = $row[0];
function escape_data ($data)
{
global $dbc; // Need the connection
if (ini_get('magic_quotes_gpc'))
{
$data = stripslashes($data);
}
return mysql_real_escape_string (trim ($data), $dbc);
}
$query1 = "INSERT INTO pics
(file_name,
file_size,
file_type,
file_use,
date)
VALUES
('{$_FILES['picture']['name']}',
'{$_FILES['picture']['size']}',
'{$_FILES['picture']['type']}',
'OBIT', NOW())";
$result1 = @mysql_query($query1);
if ($result1)
{
$extension = explode ('.', $_FILES['picture']['name']);
$uid = mysql_insert_id();
$filename = $uid.'.'.$extension[1];
if (move_uploaded_file($_FILES['picture']['tmp_name'], "./pics/$filename"))
{
$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;
}
function createthumb($name,$filename,$new_w,$new_h)
{
$system=explode('.',$name);
if (preg_match('/jpg|jpeg/',$system[1]))
{
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png/',$system[1]))
{
$src_img=imagecreatefrompng($name);
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
$pics=directory('pics','jpg,JPG,JPEG,jpeg,png,PNG');
$pics=ditchtn($pics,'tn_');
if ($pics[0]!='')
{
foreach ($pics as $p)
{
createthumb('pics/'.$p,'thumbs/tn_'.$p,60,50);
}
}
}
$message .= "Your picture has been uploaded successfully.<br>";
$query2 = "UPDATE obituary SET picture = './pics/$filename', thumb = './thumbs/$filename' WHERE obit_id = '$obit_id'";
$result2 = @mysql_query($query2);
}
else
{
echo 'File not Moved';
}
}
}
}
Still ugly, but at least now I can see where the functions begin and end (helpful hint: source code is intended to be readable by humans).
And here (buried for some inexplicable reason deep in a pile of conditionals) is
the createthumbs function:
function createthumb($name,$filename,$new_w,$new_h)
{
$system=explode('.',$name);
if (preg_match('/jpg|jpeg/',$system[1]))
{
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png/',$system[1]))
{
$src_img=imagecreatefrompng($name);
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
$pics=directory('pics','jpg,JPG,JPEG,jpeg,png,PNG');
$pics=ditchtn($pics,'tn_');
if ($pics[0]!='')
{
foreach ($pics as $p)
{
createthumb('pics/'.$p,'thumbs/tn_'.$p,60,50);
}
}
}
Which does appear to resize an image (and then calls itself for a whole list of ditchtn pics - whatever they are), but doesn't appear to do anything with the resized image; certainly it doesn't save it anywhere.