Serializing a query result to JSON?

0

I'm adding the result of a query to an array and I'm trying to serialize to Json . I am not able to print my JSON correctly, could you 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 is generating the 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

    
asked by anonymous 12.08.2016 / 21:07

1 answer

0

According to this other answer:

link

oracle is not referenced in your apache, and putting these lines

putenv("ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1"); putenv("LD_LIBRARY_PATH=/opt/app/oracle/product/11.2.0/db_1/lib:/lib:/usr/lib");

    
13.08.2016 / 02:33