Quote Originariamente inviata da Alhazred Visualizza il messaggio
Devi postare il codice PHP che ti popola l'array $dataPoints altrimenti non ci capiamo.
Comunque, da ciò che ti stampa il print_r resto convinto che usi degli apici e quelle che tu pensi siano istruzioni vengono usate come stringhe di testo.
Eccolo !

<?php

echo "<input type='button' class='btn btn-lg btn-success btn-block' value='Ritorno al menù principale' onclick=".'"top.location.href = '."'indexold.php'".'" />';


$dataPoints = array();


//Best practice is to create a separate file for handling connection to database
try{
// Creating a new connection.
// Replace your-hostname, your-db, your-username, your-password according to your database
$link = new PDO( 'mysql:host=localhost;dbname=btp_sql;charset=utf8m b4', //'mysql:host=localhost;dbname=canvasjs_db;charset=u tf8mb4',
'root', //'root',
'', //'',
array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_PERSISTENT => false
)
);

$handle = $link->prepare('select data,numero,newdate from sto_val_btptest order by data');
$handle->execute();
$result = $handle->fetchAll(PDO::FETCH_OBJ);

foreach($result as $row){

array_push($dataPoints,$row->newdate);

}
$link = null;
}
catch(PDOException $ex){
print($ex->getMessage());
}
print_r ($dataPoints);




?>


<script>

var dataPoints=<?php echo json_encode($dataPoints,JSON_HEX_QUOT);?>;
console.log(dataPoints);
</script>


Grazie
Beppe