2

I'm new to LAMP environment and I have some issue with my browser viewing ODBC queries. My php code works in the console under root, but if I run the file using www-data as the user it fails the same way as the browser.

Here's the php code:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

  $conn = odbc_connect("NetSuite", "username", "pw");

  if (!$conn) {
    die(' Could not connect: ' . odbc_error($conn));
  }
  $query = odbc_prepare($conn, "SELECT CUSTOMER_SERIAL_NUMBER FROM CUSTOMER_SERIAL_NUMBER");
  $success = odbc_execute($query, array('Data'));
  if($success)
  odbc_result_all($query);
 ?>

here is the error I'm getting in the browser and the console (when running as www-data user):

PHP Warning:  odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/opt/netsuite/odbcclient/lib64/ivoa25.so' : file not found, SQL state 01000 in SQLConnect in /var/www/html/GetNSData_1.php on line 5

Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/opt/netsuite/odbcclient/lib64/ivoa25.so' : file not found, SQL state 01000 in SQLConnect in /var/www/html/GetNSData_1.php on line 5
PHP Warning:  odbc_error() expects parameter 1 to be resource, boolean given in /var/www/html/GetNSData_1.php on line 8

Warning: odbc_error() expects parameter 1 to be resource, boolean given in /var/www/html/GetNSData_1.php on line 8

my driver folder is set to /opt/netsuite/odbcclient/lib64 here is my permission breakdown:

drwxr-xr-x   3 www-data root      4096 Jul 28 16:17 opt

drwxr-xr-x   3 www-data root      4096 Jul 28 16:17 netsuite

drwxr-xr-x   8 www-data root      4096 Aug 17 17:41 odbcclient

drwxr-xr-x   2 www-data www-data  4096 Aug 16 18:39 lib64

All files in the lib64 are set to

-rwxr-xr-x 1 www-data www-data

The php file is currently set to 777.

I just can't figure out what permission is missing or wrong to get www-data to be able to reach the driver. Any help would be greatly appreciated.

mudrock
  • 21

0 Answers0