gohmdoree Posted December 13, 2010 Share Posted December 13, 2010 I've gotten different "Notices" for "Undefined Index." For different $_POST['vars'], I've corrected with adding an isset() at the top of my if condition. I'm stumped now for how to approach my current notice. Am tempted to just block errors on my server, but don't believe that is really fixing it. I've added a multiple select array to my form. I pass it correctly and access it fine. Only thing, for checking with error checking, if it is blank, the form will repopulate. If checked, the data passes correctly. If there are no selections, then I get the Undefined Index error from PHP. I wrote a routine to check if it is null, but that doesn't seem to do it. I want to check that it is not null, and if it is, then repost the form. If I put in isset(), it would never go past. If I don't put isset(), then it will cry with the error. Any Thoughts? Link to comment https://forums.phpfreaks.com/topic/221537-undefined-index/ Share on other sites More sharing options...
gohmdoree Posted December 13, 2010 Author Share Posted December 13, 2010 After reading the isset() man pages, instead of doing a condition like below if (($_POST['item_no'] == '') || ($_POST['item_width'] == '') || ($_POST['item_description'] == '') || ($_POST['categories'] == null) || ($_POST['compositions'] == null) || ($_POST['colors'] == null) || ($_POST['patterns'] == null)){ seems like doing a condition as: if (isset($_POST['item_no'], $_POST['item_width'], $_POST['item_description'], $_POST['categories'], $_POST['compositions'], $_POST['colors'], $_POST['patterns']){ }else{ } might be the solution. Only thing, if I tried passing and it wasn't set, get the same error. Would I need a long conditional statement checking each item, posting the form accordingly, depending on if it is set or not, and pass an empty string. Link to comment https://forums.phpfreaks.com/topic/221537-undefined-index/#findComment-1146778 Share on other sites More sharing options...
gohmdoree Posted December 13, 2010 Author Share Posted December 13, 2010 Just preceded each $_POST['var'] with isset, and got rid of the error. Link to comment https://forums.phpfreaks.com/topic/221537-undefined-index/#findComment-1146814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.