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. 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 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? 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. 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)) 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()); } ?> 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! 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
Archived
This topic is now archived and is closed to further replies.