Ho inserito un codice php e nella schermata della pagina ho ricevuto questo messaggio di errore:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'....... on line 49
Ho bisogno di aiuto, grazie!!
Purtroppo sono negato in php e non capisco qual'è l'errore. Di seguito il codice; la riga rossa è la n° 49:
<?php
function productData () {
$output = array();
$output[] = array ('name' => 'Marenghi' , 'weight' => 6.3);
$output[] = array ('name' => 'Sterline' , 'weight' => 7.6);
$output[] = array ('name' => '4 Ducati' , 'weight' => 14.5);
$output[] = array ('name' => '100 Pesos' , 'weight' => 19.9);
$output[] = array ('name' => '10 Dollari' , 'weight' => 21.0);
$output[] = array ('name' => 'Krugerrand' , 'weight' => 31.6);
$output[] = array ('name' => '100 Corone' , 'weight' => 32.0);
$output[] = array ('name' => '20 Dollari' , 'weight' => 36.0);
$output[] = array ('name' => '50 Pesos' , 'weight' => 37.9);
return $output;
}
function getGoldPrice() {
$xml = new SimpleXMLElement('http://dgcsc.org/goldprices.xml', NULL, TRUE);
if ($xml === FALSE) {
return FALSE;
}
$output = array();
$output['date'] = (string)$xml['date'];
for ($i = 0 ; $i < 25 ; $i ++) {
if (strcmp((string)$xml->Price[$i]['currencycode'], 'EUR') == 0) {
$output['value'] = (float)$xml->Price[$i];
}
}
return $output;
}
?>
<html>
<head>
</head>
<body>
<?php
$gold = getGoldPrice();
$prList = productData();
echo 'Lettura del prezzo dell'oro avvenuta il '.$gold['date']."
\n";
echo 'prezzo dell'oro corrente '.$gold['value']."
\n";
echo '<table>';
echo '<thead><tr><th>Nome</th><th>Peso</th><th>Prezzo </th></tr></thead>';
foreach ($prList as $cPr) {
echo '<tr>'.
'<td>'.$cPr['name'].'</td><td>'.$cPr['weight'].'</td><td>'.$cPr['weight'] * $gold['value'].'</td>'.
'</tr>'."\n";
}
echo '</table>';
?>
</body>
</html>