calmchess Posted June 17, 2007 Share Posted June 17, 2007 my code is broken because of the following problem. I don't need you to fix the code but instead i need you to explain how to go about finding the errors and correcting them.....the code that the below variables belong to is quite complex and i've looked up everything and all the arguments seem to be there but i still get the errors....I don't think there is alot wrong with the code because on my Linux box the code works but on windows it doesn't work....I've had an expert configure my php and webserver so i know that it isn't the problem....its the code. i get 8 errors here are the errors Warning: Missing argument 1 for addNewPic(), called in C:\webserver\resize1_only\resize_only.php on line 160 and defined in C:\webserver\resize1_only\resize_only.php on line 5 i get 8 of those i tracked it down to these variables function addNewPic($dbase,$filein,$fileout,$imagethumbsize_w,$imagethumbsize_h,$green,$blue,$red){ but i don't know how to resolve it Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 17, 2007 Share Posted June 17, 2007 Well, surely it must be a case that you havn't passed all of the variables for the function when you call it? Can we see line 160 from resize_only.php? Quote Link to comment Share on other sites More sharing options...
calmchess Posted June 17, 2007 Author Share Posted June 17, 2007 line 160 is this maybe i should just post all the code and you can tell me how to fix it its open source anyway so after this post i will post it. addNewPic(); Quote Link to comment Share on other sites More sharing options...
calmchess Posted June 17, 2007 Author Share Posted June 17, 2007 here is all the code. <? function addNewPic($dbase,$filein,$fileout,$imagethumbsize_w,$imagethumbsize_h,$green,$blue,$red){ $target = "upload/"; $target = $target.time().basename( $_FILES['uploaded']['name']) ; $ok=1; $uploaded_type = $_FILES['uploaded']['type']; $uploaded_size = $_FILES['uploaded']['size']; $uploadedname = $_FILES['uploaded']['name']; $fil0 ="jpg"; $fil1 ="png"; $fil2 ="gif"; //This is our size condition if ($uploaded_size > 350000) { //echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if (!($uploaded_type==="image/gif"||$uploaded_type==="image/pjpeg"||$uploaded_type==="image/x-png")) { $ok=0; } $pos = strrpos($uploadedname, $fil0)||$pos = strrpos($uploadedname, $fil1)||$pos = strrpos($uploadedname, $fil2); if ($pos == false) { //echo "You may only upload .GIF,.JPG,and .PNG files.<br>"; $ok=0; $dbase = "default.jpg"; }else { //echo "found"; $ok=1; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { $dbase = "default.jpg"; //echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $dbase = time().basename( $_FILES['uploaded']['name']) ; //echo "The picture has been uploaded"; } else { $dbase = "default.jpg"; //echo "Sorry, there was a problem uploading your file."; } $filein = 'upload/'.$dbase; // File in $fileout = 'upload/'.$dbase; // Fileout - optional $imagethumbsize_w = $_POST['width']; // thumbnail size (area cropped in middle of image) $imagethumbsize_h = $_POST['height']; // thumbnail size (area cropped in middle of image) { // Get new dimensions list($width, $height) = getimagesize($filein); $new_width = $width * $percent; $new_height = $height * $percent; if(preg_match("/.jpg/i", "$filein")) { $format = 'image/jpg'; } if (preg_match("/.gif/i", "$filein")) { $format = 'image/gif'; } if(preg_match("/.png/i", "$filein")) { $format = 'image/png'; } switch($format) { case 'image/jpg': $image = imagecreatefromjpeg($filein); break; case 'image/gif'; $image = imagecreatefromgif($filein); break; case 'image/png': $image = imagecreatefrompng($filein); break; } $width = $imagethumbsize_w ; $height = $imagethumbsize_h ; list($width_orig, $height_orig) = getimagesize($filein); if ($width_orig < $height_orig) { $height = ($imagethumbsize_w / $width_orig) * $height_orig; } else { $width = ($imagethumbsize_h / $height_orig) * $width_orig; } if ($width < $imagethumbsize_w) //if the width is smaller than supplied thumbnail size { $width = $imagethumbsize_w; $height = ($imagethumbsize_w/ $width_orig) * $height_orig;; } if ($height < $imagethumbsize_h) //if the height is smaller than supplied thumbnail size { $height = $imagethumbsize_h; $width = ($imagethumbsize_h / $height_orig) * $width_orig; } $thumb = imagecreatetruecolor($width , $height); $bgcolor = imagecolorallocate($thumb, $red, $green, $blue); ImageFilledRectangle($thumb, 0, 0, $width, $height, $bgcolor); imagealphablending($thumb, true); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $thumb2 = imagecreatetruecolor($imagethumbsize_w , $imagethumbsize_h); // true color for best quality $bgcolor = imagecolorallocate($thumb2, $red, $green, $blue); ImageFilledRectangle($thumb2, 0, 0, $imagethumbsize_w , $imagethumbsize_h , $white); imagealphablending($thumb2, true); $w1 =($width/2) - ($imagethumbsize_w/2); $h1 = ($height/2) - ($imagethumbsize_h/2); imagecopyresampled($thumb2, $thumb, 0,0, $w1, $h1, $imagethumbsize_w , $imagethumbsize_h ,$imagethumbsize_w, $imagethumbsize_h); // Output //header('Content-type: image/gif'); //imagegif($thumb); //output to browser first image when testing if ($fileout !="")imagejpeg($thumb2, $fileout); //write to file //header('Content-type: image/pjpeg'); //imagejpeg($thumb2); //output to browser echo "Picture Resized"; } } } addNewPic(); ?> <html> <title>Resize Page</title> <body> <h1>Resize Picture</h1> <form enctype= "multipart/form-data" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Width:</td><td><input type="text" name="width" maxlength="30"></td></tr> <tr><td>Height:</td><td><input type="text" name="height" maxlength="30"></td></tr> <tr><td>upload:</td><td><input name="uploaded" type="file" ></td></tr> <tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Join!"></td></tr> </table> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 17, 2007 Share Posted June 17, 2007 Ok, yes the problem is here. On your call to your function, you simply have: addNewPic(); The function, however, requires parameters to be put into it. It requires all of the following: $dbase,$filein,$fileout,$imagethumbsize_w,$imagethumbsize_h,$green,$blue,$red If you dont fully understand functions, try googling them. First thing i found for an introduction to functions: http://www.onlamp.com/pub/a/php/2001/07/12/php_foundations.html Quote Link to comment Share on other sites More sharing options...
calmchess Posted June 17, 2007 Author Share Posted June 17, 2007 could you figure out how to fix that script i'm a flash programmer but i need that script to work for one of my flash sites.....I don't know PHP very well it took me a very long time to modify that script to get it working on linux but i really need it to work on windows so if you could help it would be greatly appriciated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.