unable to connect to database on a networked drive - php

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:

Related

ISAM Table Not Found, SQL state S0000 in SQLExecDirect

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.

Error connecting to SQL host, PHP Script: PHPVALLEY Microjob Script

I installed the php script and all wen well but the problem is at the final step, when I need to fill the database information, when I field the database information I find that i am getting an error that says "Error connecting to SQL host", so I try and try in different ways but there is no solution, nevertheless, I installed the same script on my localhost and all went well without problems, my Hosting Provider is: Siteground
Filling Database Information Image
Showing the Error Image
You must grant write permissions to the connect.php file for the user who is running the web service for example apache.
Have you ssh access to the server?
If your application cannot connect to the database you should make sure that:
Your application is using the correct MySQL hostname: localhost
Your application is using the correct MySQL database / username /
password.
Don't forget to specify your MySQL username and database with the
prefix yourusername_ in front of its given name. For example, your
cPanel username is siteground and you have named your database
joomla. In this case you have to refer to your database as
siteground_joomla;
Source: https://www.siteground.com/kb/my_script_cannot_connect_to_my_database_/
Another good idea would be to try to use your cPanel username and password for the Database User and Database Password. This will rule out whether you have granted all privileges to your database user.
Also you should change the permissions of your connect.php file to 755, as if you set them to 777, this will cause an internal server error.

Where is /usr/local/lib on online server

I have a server hosted on 000webhost.com
In the file manager there is a public_html folder where I store my website files, but no \usr folder.
Generally I could just access this file through the command line or terminal but this is not the case on this server. Unless there are command line tools that I simply couldnt find (I know it is a linux server);
I ran phpinfo() and the configuration file path was in usr/local/lib but I have no idea how to access that.
Any ideas? Thanks in advance.
Go to http://www.000webhost.com/faq.php look at the section on connecting to MySql. Your solution is likely there.
Here is a synopsis:
If you cannot connect to MySQL server, there could be some causes:
- Incorrect MySQL hostname.
Never use 'localhost' as your MySQL hostname! You can find your MySQL hostname by logging on to members area, entering control panel and clicking on MySQL icon.
- Incorrect MySQL username / password or database name.
You can find / setup MySQL username and database by clicking on MySQL icon from control panel. And you can change MySQL password by clicking on phpMyAdmin icon.
- Database failed to setup.
In a very rare cases MySQL database can fail to setup. To confirm this, please try to enter phpMyAdmin for any database. If you see database there, that means it setup was successful. And if you get access denied error by trying to enter phpMyAdmin, please delete the database and setup the same MySQL database again.
Please note that always you must give about 1 minute for any changes to apply on server.
If you still unable to connect to MySQL you check if it is server or your script problem in this way: if you can enter phpMyAdmin and see you database there, that means everything is working fine on our side. It's a problem with your PHP script.

Your configuration file contains settings (root with no password) error in easy php

using easy php. After installing the easy php, that shows "Your configuration file contains settings (root with no password) that correspond to the default MySQL privileged account. Your MySQL server is running with this default, is open to intrusion, and you really should fix this security hole by setting a password for user 'root'." (For other details see the image and the error at bottom of the image)
By this error i am not able to insert values in database
1-----> change the port number in mysql file [ right click easyphp and go to config files you can find it];
search 3306 and change it to 8088
2----->access denied error
goto C:\Users\something\Documents\EasyPHP-DevServer-14.1VC9\modules\phpmyadmin414x140419170848 open config.inc.php file
change the password to 12345 [ you mysql server password username root]
3------>
can't create your table
goto C:\Users\something\Documents\EasyPHP-DevServer-14.1VC9\modules\phpmyadmin414x140419170848\examples open create_table.sql
import sql file to your easyphp and press go ..
finally you can do anything on php

I'm trying to connect to a remote Omnis Data file with ODBC using PHP

We're wanting to create some html reports for clients for easy viewing of data within their Omnis database so that they don't have to do a full log into Omnis to get some basic information. We've been working with php and odbc and things are working without any issues on our testing environment, which is all on the same computer.
We then moved to testing it more, this time by placing the datafile onto a server, and linking the odbc driver to that datafile. It dies with:
Warning: odbc_connect() [function.odbc-connect]: SQL error: Unable to read disk (bad disk), SQL state 08001 in SQLConnect in C:\xampp\htdocs\jP\includes\database.php on line 22
The ODBC link works fine with Excel we can look at and read all the records as needed.
The datafile on the server is a direct copy of the datafile on the local computer, same user name and passwords.
Line 22 in the php file is
$odbc_conn = odbc_connect($name_odbc, $odbc_user, $odbc_pass)
The user name and password are correct, we've also tried leaving them blank, which works on the local data, but neither work with the remote data.
The server is sitting on the same network, and we have tried two different servers, with the same result for both.
Any hints would be appreciated.
Randall casts "Resurrect" on thread:
I had this exact same problem: attempting to open an OMNIS datafile over a network connection. The solution that worked for me was to set the filename in the 32-bit ODBC DSN connection manager as the network path to the file (\SERVER\Directory\File.cf1) rather than via the drive map. Using the drive map caused this error.

Categories