SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy getimagesize & mysql problem !

    hi

    am uploading the images to db, and am geting the images width and height from the temp name .

    PHP Code:
    $img_info getimagesize($HTTP_POST_FILES[image][tmp_name][$num]); 
    the strange thing when i make echo for the img_info[0] and img_info[1] , i got the real size for image, but it insert it into db always 127 x 127 !!!

    WHAY ?

  2. #2
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    PHP Code:
    $i $_FILES['image'];
    $s getimagesize($i);

    // MySQL
    $n mysql_query("INSERT INTO table (img, imgsize) VALUES ('$i', '$s')") or die(mysql_error()); 
    - the lid is off the maple syrup again!

  3. #3
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i had try it befor..out is ;

    Warning: getimagesize: Unable to open 'image' for reading.

    this the input fields :
    PHP Code:
    $n =5;
    $num=0;
            while (
    $num++ < $n)
            {
            
               
    $fileds .= "<input  class=\"input\" type=\"file\" name=\"image[$num]\" size=\"30\" value=\"$image[$num]\"><br>\n\n\n";


            }
            echo 
    $fileds

  4. #4
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    found it, bad row type in db !

  5. #5
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, you had a TINYINT column, didn't ya? SMALLINT UNSIGNED should be fine.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  6. #6
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes ..

    btw i put int, is this will be slow when i query something from db ?

    i mean if i give column longblob for value 'yes' or 'no' , is this make the query slow ?

  7. #7
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    INT just takes more space than SMALLINT. i always use the smallest column possible that will hold the range of values that i need to store.

    same thing if you used LONGBLOB to store a "yes" or "no" value; it would waste space.

  8. #8
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    waste space of what ?
    and what about the query speed in this case ?

  9. #9
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wastes disk space. also, if it's an indexed column, it will waste space in the index cache (key_buffer). and yes, when your data is larger, it could technically make queries slower.

  10. #10
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i see ..
    well thx for info


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
  •