Jump to content

[SOLVED] Double Data Returns using oci_fetch_**.


iPixel

Recommended Posts

Hello guys, to start off im completely new to using oci functions and oracle clients. So bear with me please  :).

 

Here's my code...

<?php
$sql = "SELECT * FROM user.tapit_data_today WHERE EXTENSION = '####' AND ROWNUM <=10";
$go = oci_parse($conn, $sql);
oci_execute($go);

$rowz = oci_fetch_all($go, $results, OCI_ASSOC);
?>
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<?php
for($i=0; $i<=$rowz; $i++)
{
echo "<tr>";
	foreach ($results as $data) 
	{
         echo "<td>$data[$i]</td>\n";
	}
}
echo "</tr>";


oci_close($conn);
?>

 

This works nice and dandy except the fact that i get double the results, and 1 result is like an error and the other is what i want.

 

Example :

 

This repeats quite a few times

Notice: Undefined offset: 9 in C:\Inetpub\wwwroot\Newton\oracleOCI8.php on line 43

 

and then finally on the wayyyy bottom i get my results

#### 25-APR-06 13:50 00:00:06 I 9176834031  4846  25-APR-06 NY 7171    .1 6 MISC

 

I've done some googl'ing and found out that this happens because oci fetches types of results "Associative" and "Numeric" but im not sure how to tell it to only fetch the type that works. Also im not entirely sure how to use the other oci_fetch_XXXX types since php.net isnt really helpfull here with their manual.

 

Thanks for the help.

im new to using oci functions

 

Then your first stop should be the php manual section for the function you are using - http://us3.php.net/oci_fetch_all  You would then know that $results is an array of all the rows and using a foreach() loop to iterate over $results inside of a for() loop that is iterating the number of rows will give you multiple sets of those results.

I actually took a different route... but now everytime a record is empty i get an error.. how can i fix this ?

 

while ($row = oci_fetch_array ($go, OCI_ASSOC))
{
	?> <tr>
        	<td><?php echo $row['EXTENSION']; ?></td>	
        	<td><?php echo $row['CALLDATE']; ?></td>	
        	<td><?php echo $row['TIME']; ?></td>
        	<td><?php echo $row['DURATION']; ?></td>	
        	<td><?php echo $row['CALLTYPE']; ?></td>	
        	<td><?php echo $row['PNUM']; ?></td>	
        	<td><?php echo $row['TAPIT_USER_ID']; ?></td>	
        	<td><?php echo $row['DOGNET_USER_ID']; ?></td>	
        	<td><?php echo $row['TAPIT_ZONE']; ?></td>	
        	<td><?php echo $row['DATE_LOADED']; ?></td>	
        	<td><?php echo $row['LOCATION_ID']; ?></td>	
        	<td><?php echo $row['RAW_EXTENSION']; ?></td>	
        	<td><?php echo $row['PPLX']; ?></td>	
        	<td><?php echo $row['SLSX']; ?></td>	
        	<td><?php echo $row['SLSR']; ?></td>	
        	<td><?php echo $row['DUR_MINUTES']; ?></td>	
        	<td><?php echo $row['DUR_SECONDS']; ?></td>	
        	<td><?php echo $row['CAT']; ?></td>	
        	<td><?php echo $row['TIMEOFF_FLAG']; ?></td>	
            </tr>
         <?php
}

 

Notice: Undefined index: TAPIT_USER_ID in C:\Inetpub\wwwroot\Newton\oracleOCI8.php on line 48

 

The reason for the error is that, this particular field is empty for that record. How can i fix this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.