Connect PHP to Oracle database oci pdo Fedora 25 server - Error: could not find driver

363 Views Asked by At

I can't seem to connect to an Oracle db from my webserver.

I have installed the Oracle 12.1 instantclient and sdk packages as per the Oracle instructions.

I have installed pear and pecl to install oci8 as required.

When I visit my webpage that performs a basic connect and SELECT from db, it simply displays: Error: could not find driver. Here is my webpage php code:

<?php
  try {
    $dbb = new PDO("oci:dbname=DBSERVER", "DBASE", "password");
  } catch (PDOException $e) {
    print "Error: " . $e->getMessage();
    die();
  }
  $sql = "select NAME from BUILDER.MY_SCHEMAS"; ?> <html> <head>
    <title>Results Test Page</title> </head> <body> <table width ="500" border="1" cellpadding="1" cellspacing="1">
  <tr>
    <th>Result Set</th>
      <tr> <?php
  foreach ($dbb->query($sql) as $row) {
  echo "<tr>";
  echo "<td>".$row['NAME']."</td>";
  echo "</tr>";
  }
?> </table> </body> </html>

My php.ini file, I added:

extension=oci8.so
extension_dir = "/usr/lib64/php/modules/oci8.so"
extension=pdo.so
extension_dir = "/usr/lib64/php/modules/pdo.so"

I am not sure where to go from here and I'm scratching my head as I've had this working before. Do I need to install other packages or php extensions? Or maybe there are Oracle client settings I need to change.

I've been trying to get this to work for hours now and I am tempted to throw the machine out of the nearest window at the moment!!

Or - is there a better/easier way of connecting php with an Oracle database?

Thanks in advance for any help here!

0

There are 0 best solutions below