Problem transforming collected data into a json file

0

I'm trying to write to an .json file, information I collect from a database but for some reason nothing is written.

Follow the code:     

require_once('../helpers/connect.php');
require_once('../models/marks.php');

$marks = Mark::select($pdo);

$rows = array();

if (isset($marks)) {
    foreach ($marks as $row) {
        $rows[] = array('id' => $row['id'], 'titulo' => $row['titulo'], 'descricao' => $row['decricao'], 'latitude' => $row['latitude'], 'longitude' => $row['longitude']);

    }
}

$file = fopen('c:/xampp/htdocs/hemoba/assets/js/marks.json', 'w+');
fwrite($file, json_encode($rows));
fclose($file);
?>
    
asked by anonymous 08.06.2016 / 02:25

0 answers