SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can anyone tell me why this image gallery isn't working?

    I am trying to create a simple image gallery that resizes the images, saves the images to a directory on my server and creates a reference to the images in mySQL. I've created this code which was doing everything fine but once I started trying to make it resize the images I have been having problems and am now getting the following error:

    Parse error: syntax error, unexpected ')' in /home/sites/thedaffodilsociety.com/public_html/testbox.php on line 57

    Can anyone see what the problem might be? This is the code:
    Code:
    <?php
    error_reporting(0);
    
    $uploadDir = '/home/sites/mydomain.com/public_html/images/new/';
    	$max_width = 150;
        $max_height = 150;
     
        $upfile = $image;  //$_FILES['upfile']['tmp_name');
       
        $size = getimagesize($upfile);
        //print_r($upfile);
        $width = $size[0];
        $height = $size[1];
     
        $x_ratio = $max_width / $width;
        $y_ratio = $max_height / $height;
       
        if( ($width <= $max_width) && ($height <= $max_height) )
        {
            $tn_width = $width;
            $tn_height = $height;
        }
        elseif (($x_ratio * $height) < $max_height)
        {
            $tn_height = ceil($x_ratio * $height);
            $tn_width = $max_width;
        }
        else
        {
            $tn_width = ceil($y_ratio * $width);
            $tn_height = $max_height;
        }
     
       
        $src = imagecreatefromjpeg($upfile);
       
        $dst = imagecreatetruecolor($tn_width, $tn_height);
        imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
        imagepng($dst);
        imagedestroy($src);
        imagedestroy($dst);
    
    if(isset($_POST['upload']))
    {
    $fileName = $_FILES['userfile']['name'];
    $tmpName = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];
    $member = $_POST['txtMember'];
    $role = $_POST['txtRole'];
    
    $filePath = $uploadDir . $fileName;
    
    $result = move_uploaded_file($tmpName, $filePath,);
    if (!$result) {
    echo "Error uploading file";
    exit;
    }
    
    include 'library/config.php';
    include 'library/opendb.php';
    
    if(!get_magic_quotes_gpc())
    {
    $fileName = addslashes($fileName);
    $filePath = addslashes($filePath);
    }
    
    $query = "INSERT INTO upload2 (name, size, type, path, member, role ) ".
    "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$member', '$role')";
    
    mysql_query($query) or die('Error, query failed : ' . mysql_error());
    
    include 'library/closedb.php';
    
    echo "<br>Files uploaded<br>";
    
    }
    ?>
    
    <form method="post" enctype="multipart/form-data">
    <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
    <tr>
    <td width="246">
    <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
    <input name="userfile" type="file" id="userfile">
    <input name="txtMember" type="text" id="txtMember" size="40" maxlength="50">
    <input name="txtRole" type="text" id="txtRole" size="40" maxlength="50">
    </td>
    <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
    </tr>
    </table>
    </form>
    Thanks!!!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    The parser is looking for something after the comma.
    PHP Code:
    $result move_uploaded_file($tmpName$filePath,); 

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    God, it was staring me right in the face! Thanks for the help! I don't know how that comma got there!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •