SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    NJ
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Image Dimensions on Upload

    I'm using a script to upload images and give them an id and random name and things. But when I try and add getting the image dimensions and checking if they are too big I'm getting a parse error on line 28. I'm pretty new to php so this could be a very noobish mistake. Here is the code.

    PHP Code:
    <?php
        session_start
    ();
        
        if (
    $FileToUpload_type == 'image/gif') {
          
    $ext '.gif';
        }elseif (
    $FileToUpload_type == 'image/jpeg') {
          
    $ext '.jpg';
        }elseif (
    $FileToUpload_type == 'image/x-png') {
          
    $ext '.jpg';
        }else die (
    '<stong> Wrong </strong> Photo File Type, Must be: <strong> <p> Gif <p> Jpg <p> Jpeg <p> Bmp <p> Png </strong> <p> Please Wait As You Are Sent Back To The Change Photo Page... <meta http-equiv="refresh" content="4;URL=javascript: history.go(-1)">'); 
        
        
    $newfile substr($FileToUpload, -9);
        if(
    $FileToUpload_name == '') {
          print(
    "No file was selected!");
        }elseif(
    $FileToUpload_size $MaxFileSize) {
          print(
    "The file to upload is too big");
        }else {
         
    $max_height '50'//set max height
         
    $max_width '50'//set max width
         
    $size getimagesize('$FileToUpload'); //set size varible
         
    $width $size[0]; // get width of picture
         
    $height $size[1]; // get height of picture 
          
    if ($width>$max_width) {
                print (
    "Your image is to big please choose a smaller one and try again");
         } elseif (
    $height>$max_height) {
            print (
    "Your image is to big please choose a smaller one and try again");
         }
        }else {
         
    $user $_COOKIE["rememberCookieUname"];
         
    $global_db mysql_connect('localhost','''');
         
    mysql_select_db('dugreg_assntitties'$global_db) or die("Connection error");
         
    $query "INSERT INTO pictures (filename , type , gender , age , username) VALUES ('$newfile$ext' , '$type' , '$Gender' , '$Age' , '$user')";
         
    $result mysql_query($query) or die("ERROR");
         
    move_uploaded_file($FileToUpload"/home/dugreg/public_html/boobs/images/$newfile$ext");
         echo 
    $user;
        }
        
        
    print_r($_COOKIE);
        
        
    ?>
    Parse error: parse error in /home/dugreg/public_html/boobs/usercp/uploading/upload.php on line 28
    Last edited by Paradizzle; Sep 2, 2004 at 20:14.

  2. #2
    SitePoint Zealot David C's Avatar
    Join Date
    Nov 2003
    Location
    New York!
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would help if you told us the parse error and marked line 28.

    That said, it's probably an error with mismatched brackets. I'd suggest putting brackets on their own line and indenting each block so it's easier to count brackets.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    NJ
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I gave the parse error, I think it has something to do with two else statements in a row, but I can't think of a way around that.


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
  •