Q:

I get a error when ı use php in javascript

I get a error when I use to Php in Javascript. I check a console and Error name is "Uncaught SyntaxError: Invalid or unexpected token". How I solve this error 
My code is;
var data = ["<?php
  foreach ($db->query("SELECT * FROM ev_uygunluk where evid='{$evid}' order by id ASC") as $listele) 
{
echo"
{date: ".$listele['tarih'].", value: 'rezerve'}";

}

  ?>"];

Console error line is;
consol error line

A:

You're having double quotes wrongly placed inside your brackets and your objects aren't separated correctly with commas. Try this instead:
<?php
$tmp = [];
foreach($db->query("SELECT * FROM ev_uygunluk where evid='{$evid}' order by id ASC") as $listele) {
    $tmp[] = "{date: '{$listele['tarih']}', value: 'rezerve'}";
}

echo "var data = [".implode(', ', $tmp)."]";

