Witam.
Mam problem z kodem zamieszczonym poniżej. Prosiłbym o pomoc w znalezieniu powodu występowania błędu.
Z góry dzięki za pomoc.
Kod Generuje następujący błąd :
Parse error: parse error, expecting `','' or `')'' in C:\xampp\htdocs\test\NewsUp.php on line 43
<?php
include_once 'common.inc.php';
$doc = new DOMDocument();
$root = $doc->documentElement;
$maxId = 0;
$deleteFailures = array(); foreach ($root->getElementsByTagName('author') as $xAuthor) {
$id = $xAuthor->getAttribute('id');
if ($maxId < (int)$id) $maxId = (int)$id;
if (isset($_POST['author']) and
isset($_POST['author'][$id])) { $author = $_POST['author'][$id];
if (isset($author['delete']) and
$author['delete'] == 'true') {
$okToDelete = TRUE;
while (($file = readdir($handle)) !== FALSE) { if (is_dir($fileDir . $file)) continue
; if (!eregi("^(article|news).*\.xml$", $file)) continue
; $contentItem = simplexml_load_file($fileDir . $file);
if ((string)$contentitem->authorid == (string)$id) {
$okToDelete = FALSE;
break;
}
}
if ($okToDelete) $root->removeChild($xAuthor);
else $deleteFailures[] = $id;
} else {
$name = $xAuthor->getElementsByTagName('name');
$name = $name->item(0);
$name->nodeValue = $author['name'];
$byline = $xAuthor->getElementsByTagName('byline');
$byline = $byline->item(0);
$byline->nodeValue = $author['byline'];
$email = $xAuthor->getElementsByTagName('email');
$email = $email->item(0);
$email->nodeValue = $author['email'];
}
}
}
if (isset($_POST['newauthor'])) { foreach ($_POST['newauthor'] as $author) {
if (isset($author['name'] and
trim($author['name']) != '')) { $xAuthor = $root->appendChild($doc->createElement('author'));
$xAuthor->setAttribute('id', ++$maxId);
$xAuthor->appendChild($doc->createElement('name',
$author['name']));
$xAuthor->appendChild($doc->createElement('byline',
$author['byline']));
$xAuthor->appendChild($doc->createElement('email',
$author['email']));
}
}
}
unlink($fileDir . 'news.xml'); $doc->save($fileDir . 'news.xml');
if (count($deleteFailures) > 0
) { $qs = '?';
foreach ($deleteFailures as $id) {
$qs .= "id[]=$id&";
}
?>