dezkit Posted November 4, 2008 Share Posted November 4, 2008 Hey guys, i have this gallery script i am making, but i ran into a problem: Here is my code: <?php session_start(); if(!session_is_registered(myusername)){ header("location:/admin"); } ?> <body bgcolor="#EEEEEE"> <h2>Upload</h2>(will take a while to upload) <form enctype="multipart/form-data" action="" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="999999999999999999999999" /> <table border=0> <tr> <td>Select File: <td><input name="file" type="file" /><input type="submit" name="submit" value="Upload File" /> <tr> </form> </table><br><br> <?php include("config.php"); $submit = $_POST["submit"]; if($submit == "delete"){ foreach($checkbox as $del_id){ $tbl_name="gallery"; // Table name $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); echo "File has been deleted!<br>"; } } if($submit == "Upload File"){ function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $ext = findexts ($_FILES['file']['name']) ; $ran = rand(); $ran2 = $ran."."; $sein = "./uploads/"; $target = "./uploads/"; $target = $target . $ran2.$ext; $fale = $ran2.$ext; if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "<font color=\"red\" size=\"+1\">Image has been uploaded!</font><br><br>"; if (file_exists("./uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { $filename = $_FILES["file"]["name"]; move_uploaded_file($_FILES["file"]["tmp_name"], $target); $thumbn = $sein . "th-" . $fale; cropImage(83, 60, "$target", 'jpg', "$thumbn"); include("config.php"); $thumbnailss = "th-".$fale; mysql_query("INSERT INTO gallery (thumb_url, full_url) VALUES('$thumbnailss', '$fale' ) ") or die(mysql_error()); } } } $tbl_name="gallery"; // Table name // select record from mysql $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; $result=mysql_query($sql); function cropImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[1]; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': $simg = imagecreatefrompng($source); break; } $dimg = imagecreatetruecolor($nw, $nh); $wm = $w/$nw; $hm = $h/$nh; $h_height = $nh/2; $w_height = $nw/2; if($w> $h) { $adjusted_width = $w / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h); } elseif(($w <$h) || ($w == $h)) { $adjusted_height = $h / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h); } else { imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h); } imagejpeg($dimg,$dest,100); } ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td align="center" bgcolor="#FFFFFF"> </td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Thumbnail</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Image URL</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><img src="./uploads/<? echo $rows['thumb_url']; ?>"></td> <td bgcolor="#FFFFFF"><a href="./uploads/<? echo $rows['full_url']; ?>" target="_blank"><? echo $rows['full_url']; ?></a></td> </tr> <? // close while loop } ?> </table></td> </tr> </table> <input name="submit" type="submit" id="delete" value="delete"></form> <?php // close connection; mysql_close(); ?> Here is the error: Fatal error: Out of memory (allocated 41680896) (tried to allocate 10368 bytes) in /home/cobi/public_html/admin_gallery.php on line 82 Line82: $simg = imagecreatefromjpeg($source); EDIT: I FORGOT TO STATE: This error only comes when i upload HUGE files. Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/ Share on other sites More sharing options...
DarkWater Posted November 4, 2008 Share Posted November 4, 2008 I'm going to have to take a guess here, and say that the Out of Memory error was caused by being out of memory. Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682492 Share on other sites More sharing options...
dezkit Posted November 4, 2008 Author Share Posted November 4, 2008 CPU Usage 0.1% Memory Usage 0% Disk Space Usage 9.11MB / Unlimited Straight out of cPanel Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682506 Share on other sites More sharing options...
DarkWater Posted November 4, 2008 Share Posted November 4, 2008 By out of memory, I mean that it used more memory than was allocated in the memory_limit directive in your php.ini. Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682511 Share on other sites More sharing options...
dezkit Posted November 4, 2008 Author Share Posted November 4, 2008 i have put memory_limit to 9999999999M and upload_max_filesize to 9999999999M edit: still doesnt work Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682543 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 help? Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682554 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 bUMP Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682588 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 ???? Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682594 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 PLEASE! Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682643 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 Anybody? Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682658 Share on other sites More sharing options...
kenrbnsn Posted November 5, 2008 Share Posted November 5, 2008 Stop bumping so quickly. People here don't like whiners... Where did you put the memory limit? In your php script or in the php.ini file? If you changed the php.ini file, did you restart the webserver? Ken Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682659 Share on other sites More sharing options...
DarkWater Posted November 5, 2008 Share Posted November 5, 2008 Check your phpinfo() and see if the change took. Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682660 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 Yeah, both the local and master value. Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682669 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 BTW: How do i reset the web server? I am using host gator. Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682676 Share on other sites More sharing options...
kenrbnsn Posted November 5, 2008 Share Posted November 5, 2008 If you're using a shared host, you can't restart the webserver. You might be able to put your own php.ini file into the same directory as the script. In that file put memory_limit = 64M Or put <?php ini_set('memory_limit',0); // no limit ?> into your script. Ken Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682680 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 Thank you, but now it displays another error: Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 10368 bytes) in /home/cobi/public_html/admin_gallery.php on line 82 Should i contact hostgator about this? Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682689 Share on other sites More sharing options...
kenrbnsn Posted November 5, 2008 Share Posted November 5, 2008 Yes, contact your host. Ken Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682691 Share on other sites More sharing options...
dezkit Posted November 5, 2008 Author Share Posted November 5, 2008 The live support created a ticket for higher staff members too see. But i was wondering, is there something wrong with the script? Can you guys check? Link to comment https://forums.phpfreaks.com/topic/131410-fatal-error/#findComment-682715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.