web_master Posted July 8, 2008 Share Posted July 8, 2008 hi, I have a 12 (if) errors. How can I do to put posted variables in dbase only if all the error are 0? <?php if( $_POST['something'] ) { $error[1] == 1; } else { $error[1] == 0; } if( $_POST['something2'] ) { $error[2] == 1; } else { $error[2] == 0; } if( $_POST['something3'] ) { $error[3] == 1; } else { $error[3] == 0; } if(all the errors are equal zero) { $query = mysql_query("INSERT INTO `table` ( ... } ?> Link to comment https://forums.phpfreaks.com/topic/113679-solved-array-of-errors/ Share on other sites More sharing options...
vbnullchar Posted July 8, 2008 Share Posted July 8, 2008 try this.. <?php if(array_sum($error)==0) { ... } ?> Link to comment https://forums.phpfreaks.com/topic/113679-solved-array-of-errors/#findComment-584203 Share on other sites More sharing options...
tibberous Posted July 8, 2008 Share Posted July 8, 2008 if(!count($errors)) $query = mysql_query("INSERT INTO `table` ( ... Link to comment https://forums.phpfreaks.com/topic/113679-solved-array-of-errors/#findComment-584204 Share on other sites More sharing options...
web_master Posted July 8, 2008 Author Share Posted July 8, 2008 try this.. <?php if(array_sum($error)==0) { ... } ?> this is working, THNX!!!!!! Link to comment https://forums.phpfreaks.com/topic/113679-solved-array-of-errors/#findComment-584208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.