Hello,
I have a script that resizes images and then put them in a database, when i run the function i get a windows error that the apache server crashed (and i should restard it).
There is a video of me generating the error at [
fritz-hut.com]
In this video you see me filling in the form, uploading a image and then press submit, when i hit the submit button the following function starts:
function add_leiding($naam, $img, $groep, $bio, $size) {
//little hack so we dont need to add to much in the declaration
$ext = strtolower(substr($img['name'], strrpos($img['name'], '.') + 1));
if($img['size'] > $size) {
return get_error_type("error: De afbeelding is te groot." );
} elseif($ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "gif" ) {
//the image is from the correct type, lets rescall it and add it to the database with the other information
// Set a maximum height and width
$width = 150;
$height = 150;
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($img['tmp_name']);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($img['tmp_name']);
$imgDATA = imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
$imgnewdata = addslashes(file_get_contents($imgDATA));
$sql = sprintf("INSERT INTO cms_leiding_groep(con_link, 'con_name', 'con_image', 'con_bio') VALUES('%s', '%s', '%s', '%s')",
$groep,
$naam,
$imgnewdata,
$bio);
$result = mysql_query($sql);
if(mysql_affected_rows() != '0') {
return get_error_type("success: De nieuwe leiding werdt successvol toegevoegd." );
} else {
return get_error_type("error:Kon de leiding niet toevoegen." );
}
} else {
return get_error_type("error:Alleen afbeeldingen zijn toegestaan." );
}
}
Basicly this function resizes the image, then uploads in in the database, for some reason the apatch server crashes (totaly as you can see in the movie) when the function gets called. So is this a wamp error, apache error or a big fault in my script? Shouldnt it be impossible to crash the apache server with a php script?
Thanks alot for anyone that can help me!
-Shub
Edited 1 time(s). Last edit at 08/19/2009 11:26PM by shub.