I have a local XAMPP installation for testing and an webserver for live testing. At my local environment, everything works well. But when I load it up to my server, it gives me the error:
Parse error: syntax error, unexpected '[' in /data/web/e36087/html/pdf/index.php on line 11
But everything seems correct. What can I do?
PHP-Code:
<?php
setlocale(LC_TIME, 'de_DE.UTF-8');
$xmldb = "db.xml";
$xml = simplexml_load_file($xmldb);
if(isset($_POST["remove"])) {
unlink($xml->xpath('/data//count['.$_POST["remove"].']/fulldir')[0][0]);
unlink($xml->xpath('/data//count['.$_POST["remove"].']/pdfdir')[0][0].$xml- >xpath('/data//count['.$_POST["remove"].']/filename')[0][0]);
$query = $xml->xpath('/data//count['.$_POST["remove"].']')[0][0];
unset($query[0][0]);
//Datei schreiben
$fopen = fopen($xmldb, "w");
fwrite($fopen, $xml->asXML());
fclose($fopen);
}
?>
Link to my Webhost: http://livetest.philipgraf.at/
Function array dereferencing was first added in PHP 5.4. It's likely that your host is running 5.3.
In short this means that
unlink( $xml->xpath('/data//count['.$_POST["remove"].']/fulldir')[0][0] );
must be written as this:
$path = $xml->xpath('/data//count['.$_POST["remove"].']/fulldir');
unlink( $path[0][0] );
So essentially, save your method result to a variable before using indexes.