Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't get data from oracle table

Status
Not open for further replies.

bookouri

IS-IT--Management
Feb 23, 2000
1,464
0
0
US
I have a page that pulls some data from a table:

PHP:
while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
    echo "<tr>\n";
    foreach ($row as $item) {
        echo "  <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;")."</td>\n";
    }
}

this works fine as is, but I need to be able to specify the individual columns so I can do some formatting on them. I have found dozens of examples similar to the following that should do what I need, but I can NOT get any data to return using this example.

This is from the manual.
PHP:
<?php
$connection = oci_connect("apelsin", "kanistra");
$query = "SELECT id, name FROM fruits";
$statement = oci_parse ($connection, $query);
oci_execute ($statement);
while ($row = oci_fetch_array ($statement, OCI_BOTH)) {
    echo $row[0]." and ".$row['ID']." is the same<br>";
    echo $row[1]." and ".$row['NAME']." is the same<br>";
}
?>


This is almost verbatim from the php manual, but i just can not get it to return any data. Can ANYBODY tell me what I'm doing wrong?

PHP:
while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
    echo "<tr>\n";
    echo "<td>" .$row['OJBECT_ID'] . "</td>";
    echo "<td>" .$row['OJBECT_NAME'] . "</td>";
    echo "</tr>\n";
 
THe fiirst thing would be to find out how the data is being retuened in the $row array. so why not output the entire $row variable see what it looks like.

Code:
echo "<pre>" . print_r($row,1) . "</pre>";

Are you sure your column names are OBJECT_ID and OBJECT_NAME?







----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
the object_id and object_name are definitely correct.

PHP:
while (($row = oci_fetch_array($stid, OCI_BOTH+OCI_ASSOC+OCI_RETURN_NULLS))) {
  
    echo "<pre>" . print_r($row,1) . "</pre>"; 
  
}
this code causes the browser to hang, and eventually crash...but never returns anything

 
Odd, that should just print the row.

Try just printing one row instead of all the rows.

Code:
    $row = oci_fetch_array($stid, OCI_BOTH);
  
    echo "<pre>" . print_r($row,1) . "</pre>";



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
that returns my data just like it should.

Array
(
[0] => 4
[OBJECT_ID] => 4
[1] => jpeg
[OBJECT_TYPE] => jpeg
[2] => test1.jpg
[OBJECT_FILE_NAME] => test1.jpg
[3] => desc
[OBJECT_DESC] => desc
[4] => ins by
[OBJECT_INSERTED_BY] => ins by
[5] => OCI-Lob Object
(
[descriptor] => Resource id #3
)

[OBJECT_BLOB] => OCI-Lob Object
(
[descriptor] => Resource id #3
)

)

 
So, so then what you have is a typo.

echo "<td>" .$row['OJBECT_ID'] . "</td>";
echo "<td>" .$row['OJBECT_NAME'] . "</td>";

OJBECT != OBJECT





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I'll try again with a clean page then. I must have re-typed this stuff a dozen times but as long as I know Im not missing anything major stupid.

thanks
 
You were right. I typed everything in from scratch again. Now it works. I spent hours proof reading character by character my other pages, but somehow missed whatever typo must have been there.

thanks again..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top