1

How can I return Json format from Oracle using php? I did this and debugged with firebug, there were no error and it did not return anything...but it printed done!

<?php

$user = "username";
$pass = "password";
$host = "myhost/myservicename";

$conn = oci_connect($user, $pass, $host);
$sql  = oci_parse($conn, "SELECT * FROM emp WHERE rownum <100");

oci_execute($sql);

$rows = array();
while($r = oci_fetch_assoc($sql)) {
$rows[] = $r;
 }
$locations =(json_encode($rows));
echo 'done!';
?>
2
  • remove the echo 'done' and replace it with echo $locations Commented Aug 19, 2013 at 14:18
  • You could var_dump($locations) to see the content of your encoding... Commented Aug 19, 2013 at 14:19

1 Answer 1

3

The response is what ever that you have the page print.

So change 'done!' to $locations

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.