When I am parsing a PHP array which is filled with data from a database to JavaScript, I get an error called unexpected token '<' . The code which selectes data from my database is:
$wagennummern = NULL;
$result = $db->query("SELECT * FROM `Wagenbuch`");
while($row = $result->fetch()){
$wagennummern = $row['Wagennummer'];
}
The code to use this data in JavaScript is:
var wagennummer = <?php echo '["' . implode('", "', $wagennummern) . '"]' ?>;
The Javascript is the line where the error occurs. Can anybody tell me why there is an error and how to fix this?