0
I am adding the result of a query to an array and am trying to serialize to Json. I’m not getting my printing right JSON, could help me?
My code:
<?php
ini_set('max_execution_time', 123456);
$conn = oci_connect('teste', 'teste123', '192.168.90.3/teste');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$query = oci_parse($conn, 'SELECT NR_SEQUENCIA, DS_GRUPO_TRABALHO FROM man_grupo_trabalho');
oci_execute($query);
$rows = array();
while($r = oci_fetch_assoc($query)) {
$rows[] = $r;
}
$locations =(json_encode($rows));
echo $locations;
?>
But it’s generating the error:
Warning: oci_connect(): in C: xampp htdocs billing.php on line 5
Fatal error: in C: xampp htdocs billing.php on line 9
What’s the matter? you want to print json?
– rray
At least in this code it does not print the json, I suggest, remove
echo 'done!';
and addecho $locations;
– rray
I removed according to the last history but still gave error: Warning: oci_connect(): in C: xampp htdocs billing connection.php on line 5 Fatal error: in C: xampp htdocs billing connection.php on line 9
– Ricardo Seabra
But that there seems to be error of the query, you can make a simple example p test the json, create a new file with that code
<?php json_encode(array('msg' => 'teste', 'data' => date('H:i:s')));
– rray
Actually the connection data in the publication was wrong. I already changed but the internet browser stopped printing the word done and started to assume empty, IE, page without result
– Ricardo Seabra
If you throw this query straight into the oracle of some error?
– rray
what query? SELECT NR_SEQUENCIA, DS_GRUPO_TRABALHO FROM man_group_work
– Ricardo Seabra
That same query, of the error in the bank?
– rray
The result looks normally in the oracle database, ie, I view all the records of the table
– Ricardo Seabra
see if this returns the error message
oci_execute($query) or die(print_r(oci_error($conn)));
– rray
Page still no result, even adding this last code
– Ricardo Seabra
seems to have nothing to do with json... the error message is clear about the error in connection with oracle... fix this which will probably work the rest.
– Daniel Omine