Need assistance with converting mysqli_fetch_array references to corresponding OCI references

151
January 30, 2018, at 12:37 PM

On a MySQL database, I'm using the following PHP code to successfully retrieve rows and place the contents of two columns into a table:

while ($row = mysqli_fetch_array($query))
{
  echo '<tr>
        <td>'.$row['sc_service'].'</td>
        <td>'.$row['sc_color'].'</td>
        </tr>';
}

Now, I'm trying to take this code and use it against an Oracle database. I've tried swapping in what appears to be the OCI counterpart...

while (($row = oci_fetch_array($stid1, OCI_BOTH))!= false)
{
  echo '<tr>
          <td>'.$row['sc_service'].'</td>
          <td>'.$row['sc_color'].'</td>
        </tr>';
} 

...but the column variables (sc_service and sc_color) are not being defined.

Question: Is there a different approach required to define the column variable? I'd like to use the variables in other areas of the PHP code, and not just to populate a table.

I'm able to execute the following PHP script successfully using OCI functions (a properly populated table is returned), so I know I'm connecting to the database successfully:

<?php include 'database.php'; ?>  // my Oracle database oci_connect call
<?php
$stid = oci_parse($connect, 'SELECT * FROM service_color');
if (!$stid) {
  $e = oci_error($connect);
  trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$r = oci_execute($stid);
if (!$r) {
  $e = oci_error($stid);
  trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
print "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
  print "<tr>\n";
  foreach ($row as $item) {
    print "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
  }
  print "</tr>\n";
}
print "</table>\n";
oci_free_statement($stid);
oci_close($connect);
Rent Charter Buses Company
READ ALSO
Html form post Selection Drop-down php not posting to mysql database

Html form post Selection Drop-down php not posting to mysql database

The issue seems easy enough, but I just don't get itI took a look at multiple answers one suggested this fix where I add a variable and the name of the input element I'm like alright one line easy, I set it up add the row to the database and It submits...

173
MySQL for Visual studio 1.2.7 setup wizard ended prematurely

MySQL for Visual studio 1.2.7 setup wizard ended prematurely

Created a proj from VS2013 installed mysql plugin 11

615