Permalink
Browse files

Removed undefined index notices by using empty to make sure the index…

… exists
  • Loading branch information...
1 parent e22b34e commit 16ae471c30f13be49127e5f6a729357ffa991b45 mark-nielsen committed Aug 25, 2006
Showing with 3 additions and 3 deletions.
  1. +1 −1 mod/lesson/action/insertpage.php
  2. +2 −2 mod/lesson/action/updatepage.php
@@ -148,7 +148,7 @@
$lesson->maxanswers = $lesson->maxanswers + 2;
}
for ($i = 0; $i < $lesson->maxanswers; $i++) {
- if (trim(strip_tags($form->answer[$i]))) { // strip_tags because the HTML editor adds <p><br />...
+ if (!empty($form->answer[$i]) and trim(strip_tags($form->answer[$i]))) { // strip_tags because the HTML editor adds <p><br />...
$newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
@@ -83,7 +83,7 @@
for ($i = 0; $i < $lesson->maxanswers; $i++) {
// strip tags because the editor gives <p><br />...
// also save any answers where the editor is (going to be) used
- if (trim(strip_tags($form->answer[$i])) or isset($form->answereditor[$i]) or isset($form->responseeditor[$i])) {
+ if ((!empty($form->answer[$i]) and trim(strip_tags($form->answer[$i]))) or isset($form->answereditor[$i]) or isset($form->responseeditor[$i])) {
if ($form->answerid[$i]) {
$oldanswer = new stdClass;
$oldanswer->id = clean_param($form->answerid[$i], PARAM_INT);
@@ -162,7 +162,7 @@
error("Update page: answer $i not updated");
}
}
- } elseif ($form->answerid[$i]) {
+ } elseif (!empty($form->answerid[$i])) {
// need to delete blanked out answer
if (!delete_records("lesson_answers", "id", clean_param($form->answerid[$i], PARAM_INT))) {
error("Update page: unable to delete answer record");

0 comments on commit 16ae471

Please sign in to comment.