ISAM Table Not Found, SQL state S0000 in SQLExecDirect - php

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.

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.

Related

PHP oci_connect() is working on terminal/Centos server but not on browser

I am getting error when I trying from browser.
Warning: oci_connect(): ORA-28759: failure to open file in
/var/www/myapp/abc.php on line 16
Fatal error: ORA-28759: failure to open file in /var/www/myapp/abc.php on
line 19
But when running same file from Server terminal as a root user > PHP abc.php that time oracle database output is coming.
I didn't understand why is running from terminal but not on browser.
I am using PHP7, Apache and Installed Oracle 19c home db.
I am using oci_connect to communication with oracle database from PHP code.
I think there is some permission issue to my httpd (apahce).
Please give suggestion.
Check that the web server process has access to all the Oracle client libraries and data files. Since you are using an Oracle home, make sure all the directories have 'other' access permissions set. Typically user home directories don't have this by default.
Since the app is running, some libraries are being loaded so maybe permissions are OK? Make sure you have the web server process environment variables the same as those used by your command shell to make sure the same set of Oracle client libraries are being used. (Do you also have Instant Client installed somewhere, or another Oracle home??).
The recent common causes of 'ORA-28759: failure to open file' are when Oracle cloud wallets are being used and the sqlnet.ora path to the wallet (the DIRECTORY=... bit) is not valid. ​Check the path is OK, or the Oracle Net configuration files are in the default location (and are readable). Note that with Instant Client 19.14 you can use 1-way TLS so wallets are not always needed, depending on your net configuration.
I doubt there is a problem with php.ini, since you are obviously able to call OCI8 functions. The php.ini file doesn't control behaviors of the Oracle Client libraries that are throwing the error.
Update your question with more details about how you are setting the environment and what Oracle configuration files are being used for connecting

sasql_connect(): SQLAnywhere: [-100] Database server not found

it's about more than one full day that i started sqlanywhere and i'm so interested to use it,
i worked before with sqlsrv for ms sql server and connection via php ,
but i have problem for connecting php to sqlanywhere
here is the warning message when i try to run test.php
Installation successful Using php-5.6.0_sqlanywhere.dll
Warning: sasql_connect(): SQLAnywhere: [-100] Database server not found in C:\xampp\htdocs\test.php on line 44
Connection failed
$conn = sasql_connect( "UID=DBA;PWD=sql" );
if( $conn ) {
echo "Connected successfully\n";
sasql_disconnect( $conn );
} else {
echo "Connection failed\n";
}
I'm using xampp server php 5.6 and sqlanywhere 17 developer edition.
already i downloaded the php extension and copied on ext and also added the line in php.ini (extension=php-5.6.0_sqlanywhere.dll)
demo database i ran it with cmd : dbeng17 "%SQLANYSAMP17%\demo.db".
via cmd i tried this also :
C:>dbping -d -c "uid=dba;
SQL Anywhere Server Ping U
Connected to SQL Anywhere
Ping database successful.
but when i try via php it says: Warning: sasql_connect(): SQLAnywhere: [-100] Database server not found in C:\xampp\htdocs\test.php on line 44
Connection failed
please someone tell me what is the problem ?
thank you very much.
Your PHP installation may have multiple files similar to php.ini. Make sure you are modifying the php.ini file listed in phpinfo().
- A web server such as Apache, IIS, or any web server that supports
PHP.
- PHP installed on the same computer as the web server.
- SQL Anywhere installed on the same computer as the web server.
- The client software can be used as well. SQL Anywhere PHP extension
Refrance : https://wiki.scn.sap.com/wiki/display/SQLANY/Getting+Started+with+SAP+SQL+Anywhere+and+PHP
It solved for me when I installed and used it on another system , I don't know I tried first on a system that MSSQL server was install and I couldn't run it and tried on another system that mssql server was not installed and solved :)
sorry for being late to answer and thank you very much for those who took time to help me.

MySQL No Route to Host, mysqli_connect(): (HY000/2002)

I am trying to install BugZilla on Mac OS X 10.9 (Mavericks).
I'm hitting a snag with my MySQL configuration.
I have installed MySQL from the DMG Image mysql-5.6.14-osx10.7-x86_64
MySQL seems to be installed and running ok.
I have created a user called bugs, and a database called bugs.
I confirm that I can login to MySql from the terminal command line, using the bugs username and password, and access the bugs database.
However the installation of BugZilla fails with an error connecting to MySQL. I tried a simple test and wrote this php file:
<?php
// Create connection
$con=mysqli_connect(“localhost”,”bugs”,”********”,”bugs”);
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
But it fails at line 3 with:
Warning: mysqli_connect(): (HY000/2002): No route to host in /Users/bugzilla/Sites/test_my.php on line 11
Failed to connect to MySQL: No route to host
Why is it that I can connect from the command line, but not from php?
We experienced this error because the ip subnet used by our vagrant environment was the same as the subnet of the database server. We needed to recreate the database server on a different subnet.
I just experienced a similar problem but through which it looks like there was a different problem case. I was getting the same error:
Failed to connect to the database, please check your credentials: No route to host
And we were able to figure out the problem was actually that the disk space of our database was full (our server administrator was out sick for a while, and we automatically make snapshots, but only manually delete them on a regular basis. After a few days, the snapshots took up the space of the entire server and rendered it unresponsive).
I don't know if this will be the answer to anyone with this issue, but if someone does stumble upon this same error, hopefully this might help.

connect to mySQL using xampp

Im using xampp control on macbook and trying to connect to 'localhost/phpmyadmin'. I have apache and mySQL both running but im getting an error
#1 - Can't create/write to file '/var/folders/kb/6g_npz7s1511w39k7v224gq80000gn/T/#sql4e6_1_2.MYI' (Errcode: 13)
Any ideas about what this might be or how i could connect?
Usually you'd get that error because the directory that MySQL is using to write temp files to isn't writeable by the mysql user; usually that directory would be /var/tmp or something similar. Try starting mysql with the --tmp-dir=/var/tmp and see if it still complains. See http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_tmpdir
check the port of the apache .... by selecting checkport ... and in the browser set the url as: localhost:(port number)/phpmyadmin

unable to connect to database on a networked drive

I'm trying to connect to an access database from a php script using ODBC.
When I put the db on my local c: drive create a system DSN i can connect no problem, but when it's on the networked drive I get the error:
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides., SQL state S1009 in SQLConnect in C:\wamp\www\suppliers\furniture.php on line 3
Ok so I'm guessing it's permissions somewhere anyone know specifically what/where?
Thanks,
If you used the defaults during installation then apache is running with the Local System account, which doesn't have any network privileges. So you have to make sure it runs as a (domain) user that can access the network drive. You can change this via Control Panel, Administrative Tools, Services (right click on Apache, select Properties and select a user on the Log On tab).
I had to retrieve data from a legacy database application made in MS Access 2003, so I created an ODBC DSN to do the trick. However, the Access database was in a network drive and kept getting the error described in this thread ('(unknown)' is not a valid path...) until I found out that I did not have to only choose the drive, directory and file name, from the Select Database dialog box, but also to write the entire path to the .mdb file as the database name file.
Select the drive from the Drives dropdown list or use the 'Network...' button, then select the file name and finally, in the Database Name textbox prepend the path to your .mdb file as seen in the following image:

Categories