onthespot Posted August 6, 2009 Share Posted August 6, 2009 I have a script I have tried to order several times. The code is all there, I just can't get the order correct. I needs to pass through every if statement before it will produce the added news piece echo at the bottom. Could you help with the ordering please? if (!empty($_POST)) { if(!$subject || strlen($subject = trim($subject)) == 0) echo "Subject not entered"; else if(!$comment || strlen($comment = trim($comment)) == 0) echo "Comment not entered"; else if(!$comment || strlen($comment = trim($comment)) < 10) echo "Comment too short, must be 10 characters at least"; else if (isset ($_FILES['new_image'])) { $imagename = $subject . '.jpg'; $source = $_FILES['new_image']['tmp_name']; $target = "images/news/".$imagename; $file = explode('.', $source); $ext = end($file); move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/news/" . $imagepath; //This is the new file you saving $file = "images/news/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "images/news/sml_" . $imagepath; //This is the new file you saving $file = "images/news/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; } else if ($ext !== 'jpg' || $ext !== 'jpeg') echo 'Your file must be a jpeg'; else if (!$comment || strlen($comment = trim($comment)) > 10) { echo "".$_SESSION['username'].", you have added a news piece"; mysql_query($query); } } Link to comment https://forums.phpfreaks.com/topic/169063-help-with-this/ Share on other sites More sharing options...
Mardoxx Posted August 6, 2009 Share Posted August 6, 2009 else if (!$comment || strlen($comment = trim($comment)) > 10) { echo "".$_SESSION['username'].", you have added a news piece"; mysql_query($query); } shouldn't that be else if ($comment || strlen($comment = trim($comment)) > 10) { echo "".$_SESSION['username'].", you have added a news piece"; mysql_query($query); } Link to comment https://forums.phpfreaks.com/topic/169063-help-with-this/#findComment-891996 Share on other sites More sharing options...
onthespot Posted August 6, 2009 Author Share Posted August 6, 2009 yeah i think so, can you help with the ordering? Link to comment https://forums.phpfreaks.com/topic/169063-help-with-this/#findComment-892003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.