For mange if'er?
Hey,NU fik jeg hovedpine af det ;)
Hvordan får man php til at spytte fejlmelding ud når følgende skaber et-eller-andet problem?
if ($sendmail == "yes") {
$foresp = mysql_query("SELECT id, year, month, week, day, weekday, assignmentagendagroup, assignmentagenda, version FROM $database WHERE week=$viewweek") or die (mysql_error());
while($data = mysql_fetch_array($foresp))
{
if ($data[weekday] == 0) { $mailtitle = "Hovedprojekt/opgaver i uge $data[week] - version $data[version]"; $h = "<b><i>Hovedprojekt/opgaver i uge $data[week] - version $data[version]</i></b><br><br>"; }
if ($data[weekday] == 0) if (!empty($data[assignmentagendagroup]) || !empty($data[assignmentagenda])) { $assignmentagendagroup = str_replace ("\n", "</li><li>", "$data[assignmentagendagroup]"); $assignmentagenda = str_replace ("\n", "</li><li>", "$data[assignmentagenda]"); $day = 1; $a = "<b>$translatedday[$day] den $data[day]/$data[month]:</b> <br><br>"; if (!empty($data[assignmentagendagroup])) $aa = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $ab = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>"; }
if ($data[weekday] == 1) if (!empty($data[assignmentagendagroup]) || !empty($data[assignmentagenda])) { $assignmentagendagroup = str_replace ("\n", "</li><li>", "$data[assignmentagendagroup]"); $assignmentagenda = str_replace ("\n", "</li><li>", "$data[assignmentagenda]"); $day = 2; $b = "<b>$translatedday[$day] den $data[day]/$data[month]:</b> <br><br>"; if (!empty($data[assignmentagendagroup])) $ba = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $bb = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>"; }
if ($data[weekday] == 2) if (!empty($data[assignmentagendagroup]) || !empty($data[assignmentagenda])) { $assignmentagendagroup = str_replace ("\n", "</li><li>", "$data[assignmentagendagroup]"); $assignmentagenda = str_replace ("\n", "</li><li>", "$data[assignmentagenda]"); $day = 3; $c = "<b>$translatedday[$day] den $data[day]/$data[month]:</b> <br><br>"; if (!empty($data[assignmentagendagroup])) $ca = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $cb = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>"; }
if ($data[weekday] == 3) if (!empty($data[assignmentagendagroup]) || !empty($data[assignmentagenda])) { $assignmentagendagroup = str_replace ("\n", "</li><li>", "$data[assignmentagendagroup]"); $assignmentagenda = str_replace ("\n", "</li><li>", "$data[assignmentagenda]"); $day = 4; $d = "<b>$translatedday[$day] den $data[day]/$data[month]:</b> <br><br>"; if (!empty($data[assignmentagendagroup])) $da = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $db = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>"; }
if ($data[weekday] == 4) if (!empty($data[assignmentagendagroup]) || !empty($data[assignmentagenda])) { $assignmentagendagroup = str_replace ("\n", "</li><li>", "$data[assignmentagendagroup]"); $assignmentagenda = str_replace ("\n", "</li><li>", "$data[assignmentagenda]"); $day = 5; $e = "<b>$translatedday[$day] den $data[day]/$data[month]:</b> <br><br>"; if (!empty($data[assignmentagendagroup])) $ea = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $eb = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>"; }
if ($data[weekday] == 5) if (!empty($data[assignmentagendagroup]) || !empty($data[assignmentagenda])) { $assignmentagendagroup = str_replace ("\n", "</li><li>", "$data[assignmentagendagroup]"); $assignmentagenda = str_replace ("\n", "</li><li>", "$data[assignmentagenda]"); $day = 6; $f = "<b>$translatedday[$day] den $data[day]/$data[month]:</b> <br><br>"; if (!empty($data[assignmentagendagroup])) $fa = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $fb = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>"; }
if ($data[weekday] == 6) if (!empty($data[assignmentagendagroup]) || !empty($data[assignmentagenda])) { $assignmentagendagroup = str_replace ("\n", "</li><li>", "$data[assignmentagendagroup]"); $assignmentagenda = str_replace ("\n", "</li><li>", "$data[assignmentagenda]"); $day = 0; $g = "<b>$translatedday[$day] den $data[day]/$data[month]:</b> <br><br>"; if (!empty($data[assignmentagendagroup])) $ga = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $gb = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>"; }
}
mail("$sendtoemail", "$mailtitle", "$h$a$aa$ab$b$ba$bb$c$ca$cb$d$da$db$e$ea$eb$f$fa$fb$g$ga$gb", "From: $sendfrominfo <$sendfrommail>\nContent-type: text/html; charset=iso-8859-1");
}
Det skal nævnes at det virkede fint før jeg tilføjede de to if-sætninger inde i hvert af de overordnede 7 if'er, altså må jeg næsten konkludere at de sidste dele i de 7 if'er...
if (!empty($data[assignmentagendagroup])) $ga = "<i>I gruppen:</i><li>$assignmentagendagroup</li><br>" if (!empty($data[assignmentagenda])) $gb = "<i>Hjemme:</i><li>$assignmentagenda</li><br><br>";
...som skaber problemer, men det kan jeg ikke helt forstå.
Problemet er, når de 2 problematiske under-if'er er tilføjet, viser hjemmesiden bare hvidt, og når de ikke er der fungere hele siden fint :(
Håber nogen kan hjælpe ;)