The Little Guy Posted October 15, 2007 Share Posted October 15, 2007 I have never done this, but I have an if/else statement, and if I don't want anything to happen in the if statement, should I leave it empty or is there something that I could add??? A simple example (my actual code is much longer): <?php if(empty($_POST['fname'])){ }else{ $name = $_POST['fname'] mysql_query("INSERT INTO name(`first`) VALUES ('$name')); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/73354-empty-ifelse/ Share on other sites More sharing options...
trq Posted October 15, 2007 Share Posted October 15, 2007 <?php if(!empty($_POST['fname'])){ $name = $_POST['fname'] mysql_query("INSERT INTO name(`first`) VALUES ('$name')); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/73354-empty-ifelse/#findComment-370090 Share on other sites More sharing options...
kenrbnsn Posted October 15, 2007 Share Posted October 15, 2007 Why don't you just test for the "false" condition: <?php if (!empty($_POST['fname'])) { $name = mysql_real_escape_string(stripslashes($_POST['name'])); $rs mysql_query("INSERT INTO name(`first`) VALUES ('$name')); }?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/73354-empty-ifelse/#findComment-370091 Share on other sites More sharing options...
The Little Guy Posted October 15, 2007 Author Share Posted October 15, 2007 I was just wondering if there was something for the if, that was similar to loops break statement. Quote Link to comment https://forums.phpfreaks.com/topic/73354-empty-ifelse/#findComment-370094 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.