Hi
I am stumped with a script that works quite well to display data from an oracle db using oci_connect, oci_parse and oci_fetch.
When the script does not find a result matching the query parameters, I want to send a header 400 not found message.
I have tried lots of tests and I can't get it to work. The best I have gotten is a blank page.
Here are some relevant parts of the script:
OK, after the while (oci_fetch($stmt)) { line, I want to insert something like
and of course a trailing brace }
I have also tried (after the while (oci_fetch($stmt)) { line)
This does prevent any further display and results in a blank page.
But when I trail it by
Nothing happens, still a blank page.
I have also tried a number of test phrases (echo 'foo'
I just can't get it to recognize the IF ELSE statements.
What am I missing? Is it something to do with the way oci returns the oracle data? Am I putting this in the wrong place?
Any comments appreciated greatly.
Thanks
Mike
I am stumped with a script that works quite well to display data from an oracle db using oci_connect, oci_parse and oci_fetch.
When the script does not find a result matching the query parameters, I want to send a header 400 not found message.
I have tried lots of tests and I can't get it to work. The best I have gotten is a blank page.
Here are some relevant parts of the script:
Code:
if (!$conn = oci_connect('user', 'password', '//localhost/XE')) {
$err = oci_error();
trigger_error('Could not establish a connection: ' .
$err['message'], E_USER_ERROR);
}
$query = "select * from NPI_DATA_$state where NPI = '$in_npi'";
$stmt = oci_parse($conn, $query);
oci_define_by_name($stmt, "NPI", $NPI);
<snip DEFINE VARIABLES>
if (!oci_set_prefetch($stmt, 5)) {
trigger_error('Failed to set the number of rows to be
prefetched', E_USER_WARNING);
}
if (!oci_execute($stmt, OCI_DEFAULT)) {
$err = oci_error($stmt);
trigger_error('Query failed: ' . $err['message'], E_USER_ERROR);
}
while (oci_fetch($stmt)) {
<snip ALL ACTIVITY>
}
OK, after the while (oci_fetch($stmt)) { line, I want to insert something like
Code:
if ($NPI == '') {
header("HTTP/1.0 404 Not Found");
include ('notfound.html');
exit;
}
else {
and of course a trailing brace }
I have also tried (after the while (oci_fetch($stmt)) { line)
Code:
if ($NPI != '') {
This does prevent any further display and results in a blank page.
But when I trail it by
Code:
}
else {
header("HTTP/1.0 404 Not Found");
include ('notfound.html');
exit;
}
Nothing happens, still a blank page.
I have also tried a number of test phrases (echo 'foo'
I just can't get it to recognize the IF ELSE statements.
What am I missing? Is it something to do with the way oci returns the oracle data? Am I putting this in the wrong place?
Any comments appreciated greatly.
Thanks
Mike