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')); } ?> 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')); } ?> 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 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. Link to comment https://forums.phpfreaks.com/topic/73354-empty-ifelse/#findComment-370094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.