Switch error please help.

Discussion in 'PHP' started by dkin69, Dec 8, 2007.

  1. #1
    I cant seem to figure this out. This is the error Im getting.

    Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 6800 bytes) in /home/hoot33/public_html/host/includes/core.func.php on line 485

    This is the switch

    Line 485 is line saying Default:

    switch($image[type])
    {
    case 1:
    $type = "gif";
    if( function_exists("imagecreatefromgif") )
    {
    $s_img = @imagecreatefromgif($filename);
    break;
    }
    case 2:
    $type = "jpg";
    $s_img = imagecreatefromjpeg($filename);
    break;
    case 3:
    $type = "png";
    $s_img = imagecreatefrompng($filename);
    break;
    default:
    //convert to new type file in temp dir!
    $old_type=strtolower(strrchr($filename,'.'));
    $tmp_filename = convertFiletype($filename,'.jpg');
    $s_img = imagecreatefromjpeg($tmp_filename);
    $converted=1;
    }

    If anyone can help Id be very grateful
     
    dkin69, Dec 8, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    How big is the image?

    The problem is not in your switch. PHP is telling you that it's running out of memory. (Probably because of an over sized image.)
     
    nico_swd, Dec 8, 2007 IP
  3. dkin69

    dkin69 Active Member

    Messages:
    644
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #3
    image is 336 kb max allowed file size is 5 mb
     
    dkin69, Dec 8, 2007 IP
  4. ven123

    ven123 Banned

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Can you post the whole code here please?
     
    ven123, Dec 8, 2007 IP
  5. Gawk

    Gawk Peon

    Messages:
    427
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Check your phi.ini for the memory_limit setting, it may be too small. You are running out of memory at 4Mb at the moment.
     
    Gawk, Dec 8, 2007 IP
  6. nuketro0p3r

    nuketro0p3r Peon

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    please correct me if i am wrong but as far as i know
    41,943,040 bytes are equal to 40 MB
     
    nuketro0p3r, Dec 8, 2007 IP
  7. Gawk

    Gawk Peon

    Messages:
    427
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #7
    heh heh - opps I mis-read that one ;) Ignore my previous post - 41Mb should be enough!

    Do you get the same error for both gif and jpg images?
     
    Gawk, Dec 8, 2007 IP
  8. dkin69

    dkin69 Active Member

    Messages:
    644
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #8
    No, just jpg, png also works.

    The script seems to work if I upload a single file but as soon as I upload multiple I get the error (multiple being 9)

    http://papacelebs.com/host/index.php

    thats the site
     
    dkin69, Dec 8, 2007 IP