1
  • PHP Version: 7.0.14
  • Working on Windows Server 2012
  • Database files are in D: drive
  • Website/Application is assigned to the Application pool correctly
  • Assigned Application pool has the permissions to D: drive

Trying to connect and fetch information from ToppSpeed Database.

Created DSN correctly using Topspeed ODBC Driver.

I have created a sample script to verify if it is working or not.

odbctest.php

       $conn=odbc_connect("DSN_NAME",'',''); //Make a coonection to DSN

        if (!$conn){
            exit("Connection Failed: " . $conn);
        }

        $sql="SELECT * FROM ExampleTableName"; // Query String

        $rs=odbc_exec($conn,$sql);            //Execute Query <--- Error Line

        if (!$rs) {
            exit("Error in SQL");
        }

        while (odbc_fetch_row($rs)){
            var_dump(odbc_result($rs,1));
        }

        odbc_close($conn);

Error:

PHP Warning: odbc_exec(): SQL error: [SoftVelocity Inc.][TopSpeed ODBC Driver][ISAM]ISAM Table Not Found, SQL state S0000 in SQLExecDirect in C:\inetpub\wwwroot\projectFolder\odbctest.php on line 9

  • Working: When I run same file on PHP inbuilt server using command > php -S localhost:8002 and run file in a browser at http://localhost:8002/odbctest.php Everything works fine.

  • Working: When I run file in command line > php odbctest.php It works fine I got data from the table.

  • Not Working: I have added the website in IIS Manager, bind the website(physical path is C:\inetpub\wwwroot\projectFolder ) with the local IP
    When I open that odbctest.php in a browser with local IP I am getting Table NOT Found error.

Same Script, Only difference is it is running on Command Line and not on IIS server, It is running on PHP inbuilt server and not working on IIS.

other Technical Difference is

I have put one PHP file to see PHP information on both servers. Here is the only difference I found in that.

  • Working On PHP inbuilt server: In PHP info Server API is: Built-in HTTP server
  • Not working on IIS Server: in PHP info Server API is: CGI/FastCGI

there is not issue in DSN string because when I change the DSN string with unknown it identifies that there is something wrong in DSN string.

I think there might be some permission issue when trying to access data from IIS server (PHP runs on CGI/FastCGI).

I am wondering if there is permission issue why the error says table not found!!

I don't find any good documentation for TopSpeed Database connection error as this database is not widely used.

Any suggestion or idea? Please advise. Thank you in advance.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Lahar Shah
  • 7,032
  • 4
  • 31
  • 39

1 Answers1

0

The database SQL error was not stating anything about permission,

so I created a simple another PHP script to append data to TEXT file.

I ran that PHP script with two test cases on the IIS server

  • Test Case 1: Write in a text file which resides in the project directory(same server) And PHP script executes correctly and it wrote data to text file.

  • Test Case 2: I change the text file path with the file D:\some_directory\logfile.txt (Resides on D drive) And when I ran it again script again I got the following error:

Warning: file_put_contents(D:\some_directory\logfile.txt): failed to open stream: Permission denied in C:\inetpub\wwwroot\project-directory\write.php on line 12

It confirms there is some problem with the Permissions

App pool assigned to the Website in IIS manager already had the permission to D: Driver. So it was not the problem. In more research, I found that

we need to identify the USER first that we need to provide the permissions and the user is the value of "Anonymous user identity"

https://stackoverflow.com/a/32033941/5236174

https://www.iis.net/configreference/system.webserver/security/authentication/anonymousauthentication?showTreeNavigation=true

I saw that the value of Anonymous user identity was not the Application Pool!!

I changed that to the Application pool identity.

So now the website/application's anonymous user identity become the App pool and that has correct permissions.

Afthesethis changes, everything works perfectly fine as there is no permission issue.

Lahar Shah
  • 7,032
  • 4
  • 31
  • 39