4 Replies Latest reply: Jan 4, 2007 1:26 PM by cj RSS

    duplicate columns

    sadora
      Can you tell me why I got duplicate columns when I try to run example from 2 Day Plus PHP Developer Guide - B25317-01

      ===================================================
      <?php
      require('anyco_ui.inc');

      // Create a database connection
      $conn = oci_connect('hr','hr','mytcp');
      ui_print_header('== Departments ==');
      do_query($conn,'SELECT * FROM DEPARTMENTS');
      ui_print_footer(date('Y-m-d H:i:s'));

      // Execute query and display results
      function do_query($conn,$query)
      {
      $stid = oci_parse($conn,$query);
      $r = oci_execute($stid, OCI_DEFAULT);

      print '<table border="1">';
      while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)){
      print '<tr>';
      foreach ($row as $item) {
      print '<td>'
      .($item ? htmlentities($item): ' ').'</td>';
      }
      print '</tr>';
      }
      print '</table>';
      }

      ?>
      =========================================

      Everything looks fine but in response I got HTML table with duplicated columns.
        • 1. Re: duplicate columns
          514663
          Can you provide a sample of the output with duplicate columns please.

          TY
          • 2. Re: duplicate columns
            sadora
            Yes, i try to show what it looks like.
            In HTML it looks like that
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
            <html>
            <head>
            <meta http-equive="Content-Type" content="text/html; charset=ISO-8859-1">
            <link rel="stylesheet" type="text/css" href="style.css">
            <title>Any Co.: == Departments ==</title>
            </head>
            <body>
            <h1>== Departments ==</h1><table border="1">
            <tr>
            <td>10</td>
            <td>10</td>
            <td>Administration</td>
            <td>Administration</td>
            <td>200</td>
            <td>200</td>
            <td>1700</td>
            <td>1700</td>
            </tr>
            <tr>
            <td>20</td>
            <td>20</td>
            <td>Marketing</td>
            <td>Marketing</td>
            <td>201</td>
            <td>201</td>
            <td>1800
            </td>
            <td>1800</td>
            </tr>
            <tr>
            <td>30</td>
            <td>30</td>
            <td>Purchasing</td>
            <td>Purchasing</td>
            <td>114</td>
            <td>114</td>
            <td>1700</td>
            <td>1700</td>
            </tr>
            <tr><
            td>40</td>
            <td>40</td>
            <td>Human Resources</td>
            <td>Human Resources</td>
            <td>203</td>
            <td>203</td>
            <td>2400</td>
            <td>2400</td>
            </tr>
            <tr>
            <td>50</td>
            <td>50</td>
            <td>Shipping</td>
            <td>Shipping</td>
            <td>121</td><td>121</td><td>1500</td><td>1500</td></tr><tr><td>60</td><td>60</td><td>IT</td><td>IT</td><td>103</td><td>103</td><td>1400</td><td>1400</td></tr><tr><td>70</td><td>70</td><td>Public Relations</td><td>Public Relations</td><td>204</td><td>204</td><td>2700</td><td>2700</td></tr><tr><td>80</td><td>80</td><td>Sales</td><td>Sales</td><td>145</td><td>145</td><td>2500</td><td>2500</td></tr><tr><td>90</td><td>90</td><td>Executive</td><td>Executive</td><td>100</td><td>100</td><td>1700</td><td>1700</td></tr><tr><td>100</td><td>100</td><td>Finance</td><td>Finance</td><td>108</td><td>108</td><td>1700</td><td>1700</td></tr><tr><td>110</td><td>110</td><td>Accounting</td><td>Accounting</td><td>205</td><td>205</td><td>1700</td><td>1700</td></tr><tr><td>120</td><td>120</td><td>Treasury</td><td>Treasury</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>130</td><td>130</td><td>Corporate Tax</td><td>Corporate Tax</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>140</td><td>140</td><td>Control And Credit</td><td>Control And Credit</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>150</td><td>150</td><td>Shareholder Services</td><td>Shareholder Services</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>160</td><td>160</td><td>Benefits</td><td>Benefits</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>170</td><td>170</td><td>Manufacturing</td><td>Manufacturing</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>180</td><td>180</td><td>Construction</td><td>Construction</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>190</td><td>190</td><td>Contracting</td><td>Contracting</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>200</td><td>200</td><td>Operations</td><td>Operations</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>210</td><td>210</td><td>IT Support</td><td>IT Support</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>220</td><td>220</td><td>NOC</td><td>NOC</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>230</td><td>230</td><td>IT Helpdesk</td><td>IT Helpdesk</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>240</td><td>240</td><td>Government Sales</td><td>Government Sales</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>250</td><td>250</td><td>Retail Sales</td><td>Retail Sales</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>260</td><td>260</td><td>Recruiting</td><td>Recruiting</td><td></td><td></td><td>1700</td><td>1700</td></tr><tr><td>270</td><td>270</td><td>Payroll</td><td>Payroll</td><td></td><td></td><td>1700</td><td>1700</td></tr></table> <div class="footer">

            <div class="date">2006-09-08 00:45:18</div>
            <div class="company">Any Co.</div>
            </div>
            • 3. Re: duplicate columns
              554545
              did you ever get an answer to this? I can't figure it out either.
              • 4. Re: duplicate columns
                cj
                The oci_fetch_array() call now returns the data indexed both
                numerically and associatively. The Oracle guide was written prior to
                this change in PHP. The doc writer has been informed of the
                correction:

                Change code line, adding "OCI_ASSOC+", to read:
                       while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
                This is due to PHP's fix for http://bugs.php.net/bug.php?id=37487


                -- cj