Jump to content

Undefined Index


gohmdoree

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.