It is necessary to connect to the potgeSQL database and output the results in JSON format. I do this:
<?php header('content-type: application/json; charset=utf-8'); $success = 'true'; $message = "Загруженные данные"; $connectString = 'host=localhost dbname=stocks_db user=postgres password=95161617'; $link = pg_connect($connectString); if (!$link) { $success = 'false'; $message = "Ошибка соединения"; } else { $sql = "select *, open - last as change from stocks"; if( !$result = pg_query($link, $sql) ) { $success = 'false'; $message = "Ошибка выполнения запроса"; }; $rows = array(); while($r = pg_fetch_assoc($result)) { switch ($r['split']) { case 't': $r['split']=true; break; case 'f': $r['split']=false; break; } $rows[] = $r; } } print "{\"success\":$success,\"message\":\"$message\",\"data\":"; print json_encode($rows); print "}"; ?> But as a result - an empty tab in the browser !!
What is a mistake in me? How to fix it ???
Ошибка выполнения запросаand any decent editor shows it all the more - Alex Shimanskyphpso that it can also show your errors ..ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1);ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1);- Alexey Shimanskyselect *, open - last as change from stocksand conceived? spaces inopen - last... and is there such a column? - Alexey Shimansky