Featured post
wordpress - Undefined index errors (PHP) -
i'm getting notices of undefined index "id" on lines 3, 6 , 7 in code. can't figure out i'm doing wrong:
if ( isset($_post['action']) && $_post['action'] == 'save' ) { foreach ($options $value) { if(($value['type'] === "checkbox" or $value['type'] === "multiselect" ) , is_array($_request[ $value['id'] ])) { $_request[ $value['id'] ]=implode(',',$_request[ $value['id'] ]); //this take array , make 1 string } $key = $value['id']; $val = $_request[$key]; $settings[$key] = $val; }
i'm thinking small thing fix haven't had luck i've tried. 1 thing did run var_dump($key) , $key null , it's not. i'm assuming has this.
this part of options page wordpress theme, way. code runs part of "save" function.
the script works if debug mode turned off, when debug mode on, these notices pop when hitting save button on options page. in advance insights, , let me know if need post more code give more context.
edit: i've posted options page in pastebin. it's long. contains t13lo's fixes. problem code on line 1957. thanks: http://pastebin.com/ngx6qzgr
you can change line 3 to:
if ( ($value['type'] === "checkbox" || $value['type'] === "multiselect" ) && isset($_request['id']) && is_array($_request[ $value['id'] ]) )
however, rest of code in foreach seems dependent upon $value['id']
. value not being set may make these lines:
$key = $value['id']; $val = $_request[$key]; $settings[$key] = $val;
irrelevant if $value['id']
not set. if that's case, placing of code in foreach within if (isset($value['id'])) {
may appropriate.
you'll need further analyze , understand code (and needs be) doing in order determine correct logic.
- Get link
- X
- Other Apps
Comments
Post a Comment