s1yman Posted August 18, 2008 Share Posted August 18, 2008 Hi, I kinda cheated with this script by combining two tutorials to get it to do what I wanted. Only I've now ended up with two if/else statements at the end. Can I merge these to just say if "all of this" rather than two seperate statements? if(move_uploaded_file($_FILES['one']['tmp_name'], $target)) { echo "The image ". basename( $_FILES['name']['type']). " has been uploaded, and your information has been added to the directory"; } else { echo "Sorry, there was a problem uploading your file."; } if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/120238-solved-compile-two-if-statements/ Share on other sites More sharing options...
Jabop Posted August 18, 2008 Share Posted August 18, 2008 ... I see one if statement Quote Link to comment https://forums.phpfreaks.com/topic/120238-solved-compile-two-if-statements/#findComment-619386 Share on other sites More sharing options...
s1yman Posted August 18, 2008 Author Share Posted August 18, 2008 hmm .. me too - lol. That better? Quote Link to comment https://forums.phpfreaks.com/topic/120238-solved-compile-two-if-statements/#findComment-619388 Share on other sites More sharing options...
revraz Posted August 18, 2008 Share Posted August 18, 2008 They are totally unrelated, should leave them seperate. Quote Link to comment https://forums.phpfreaks.com/topic/120238-solved-compile-two-if-statements/#findComment-619390 Share on other sites More sharing options...
Maq Posted August 18, 2008 Share Posted August 18, 2008 If you did want to combine them use || (or). Something like this: if(move_uploaded_file($_FILES['one']['tmp_name'], $target) || !mysql_query($sql,$con)) Quote Link to comment https://forums.phpfreaks.com/topic/120238-solved-compile-two-if-statements/#findComment-619421 Share on other sites More sharing options...
dezkit Posted August 18, 2008 Share Posted August 18, 2008 <?php if(mysql_query($sql,$con)){ if(move_uploaded_file($_FILES['one']['tmp_name'], $target)) { echo "The image ". basename( $_FILES['name']['type']). " has been uploaded, and your information has been added to the directory"; } else { echo "Sorry, there was a problem uploading your file."; } die('Error: ' . mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/120238-solved-compile-two-if-statements/#findComment-619427 Share on other sites More sharing options...
s1yman Posted August 18, 2008 Author Share Posted August 18, 2008 ah-ha.. cheers lads! Quote Link to comment https://forums.phpfreaks.com/topic/120238-solved-compile-two-if-statements/#findComment-619443 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.