FastCGI process exited unexpectedly on new PDO call to MSAccess - php

I am attempting to set up a website on my Windows 10 machine using IIS. I can successfully load a simple php file (using PHP 8.1).
When I attempt a new PDO call to MSAccess I get:
HTTP Error 500.0 - Internal Server Error
C:\php\php-cgi.exe - The FastCGI process exited unexpectedly
My code is
$dbName = $_SERVER["DOCUMENT_ROOT"] . "\\vhs\VHS.accdb";
try {
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=$dbName;Uid=admin;");
}
catch (PDOException $e) {
echo $e->getMessage();
}
Nothing gets placed into the php_errors.log.
I have both
extension=pdo_odbc.dll
extension=php_pdo_odbc.dll
in my php.ini file (and both exist in the ext folder).
I have tried the following:
1 - a different MSAccess database (both another .accdb and an old .mdb) ... same error
2 - using the incorrect driver name (for example "Microsoft Blah Driver") ... this results in a PDOException "SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified" so I believe I have the driver spelled correctly in my original code
The Microsoft Access Driver (*.mdb, .accdb) name matches the one I see in the 64-bit ODBC administrator. If I instead use Microsoft Access Driver (.mdb) which appears in the 32-bit administrator I get the 'Data source name not found' error as well.
Does anyone have any suggestions for things to check / try?

Related

PHP on IIS doesn't load sqlsrv extension

I'm trying to put together a page that can submit data from a form to an MSSQL database via PHP. I've got PHP installed successfully (phpinfo() runs fine even on a remote computer) but it will not load the sqlsrv extension. I know that I'm editing the right php.ini file because I have another extension added (wincache) and it is loading fine, confirmed with both phpinfo() and get_loaded_extensions().
The logs aren't telling me anything. PHP Manager on IIS is telling me that the sqlsrv extension files are enabled. I've restarted the website, the server, and the computer, and nothing's working.
I'm using PHP 7.1.1 on a Windows 7 Ultimate machine. It's running in x64 mode, Non-Thread Safe. I've made sure that the extension files I enabled are the x64, non-thread-safe ones. I don't know what else to check or what more info I need to provide.
EDIT: I ran php-cgi.exe as this page suggested, and it came out with the error mesages:
[31-Mar-2017 22:38:12 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\iis express\PHP\v7.1\ext\php_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
in Unknown on line 0
[31-Mar-2017 22:38:17 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\iis express\PHP\v7.1\ext\php_pdo_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
in Unknown on line 0
Does this mean that the problem is in the extension DLLs themselves? How would I even go about fixing that?
EDIT 2: ImClarky nailed the problem in that I was apparently using a way outdated version of the extension. I've got it working, but now my authentication is failing for reasons I don't understand:
function connect_sql() {
/* Specify server and connection attributes */
$serverName = "(local)";
/* Get UID and PWD from app-specific files */
$uid = file_get_contents("C:\AppData\uid.txt");
$pwd = file_get_contents("C:\AppData\pwd.txt");
$connectionInfo = array("UID" => $uid,
"PWD" => $pwd,
"Database" => "database_name");
/* Connect using SQL Server Auth */
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false)
{
echo "Unable to connect.</br>";
//die(print_r(sqlsrv_errors(), true));
die(print_errors());
}
else {
echo "Connection Successful";
}
/* Free connection resources */
sqlsrv_close($conn);
}
I've double checked that I am using the correct username and password, and I even went in and created an entirely new login using the exact UID and password I'm trying. I still get the following error message every time:
Unable to connect.
SQLSTATE: 28000
code: 18456
message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'username'.
SQLSTATE: 28000
code: 18456
message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'username'.
Make sure you add .dll file for extension folder used by php.ini
Also chose correct driver of SQLSRv matched your running PHP
SQLSRv sqlsrv from official microsoft page

PHP 64 bit - Teradata ODBC driver failure - system error 126 'specified module cannot be found' -

I have installed PHP 5.6.30 64 bit on Windows Server 2012 along with Teradata ODBC driver.
Whenever I test the PHP connection I receive an error
Warning: odbc_connect(): SQL error: Specified driver could not be loaded due to system error 126: The specified module could not be found. (Teradata, C:\Program Files\Teradata\Client\15.00\ODBC Driver for Teradata nt-x8664\Lib\tdata32.dll)., SQL state IM003 in SQLConnect
EDIT: C:\Program Files\Teradata\Client\15.00\ODBC Driver for Teradata nt-x8664\Lib\tdata32.dll does definitely exist on that specific path. Also, using tdxodbc.exe to test the ODBC connection works normally using tdata32.dll, so it appears to be some issue with PHP.
I have installed Teradata ODBC via GSS > ICU > ODBC from the Utilities package based on a related thread however still experiencing the same error. I can make a successful 32-bit ODBC connection via SQL assistant. I have tried a DSN / DSN-less ODBC connection via PHP but same error occurs.
I have been unable to find any clear indication of what the issue is - any idea?

How to connect from cakePHP3 to MSSQL Server

(I develop on a Windows System with XAMPP and use cakePHP3)
I want to connect from my cakePHP3 Localhost application, to a external SQL Server (installed on a external Windows Server 2012 r2).
In my app.php I config my Server and that is how I test the connection:
try {
$connection = ConnectionManager::get('sqlServer');
$connected = $connection->connect();
}catch (Exception $connectionError) {
echo "not";
}
echo "connected";
On testing I get this error:
A Database connection using was missing or unable to connect.
The database server returned this error: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712
So I go to my Server and Installed the needed extensions (ODBC Driver 11 for SQL Server). But I get still the same Error.
Is it possible to connect to the external Server from Localhost? Or did I make a mistake?

[unixODBC][Driver Manager]Data source name not found, and no default driver specified

I'm updating a application to stop using 'mssql_connect' to use PDO with ODBC for PHP 7.
Locally, I'm using XAMPP on Windows 8 and my application works fine. However, when I upload it to the Ubuntu server (Locaweb hosting, in Brazil) it returns the following error:
PDOException: SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified in /public_html/user/log-connections/connection.php:28 Stack trace: #0 /public_html/user/log-connections/connection.php(28): PDO->__construct('odbc:Driver={SQ...') #1 /public_html/user/log-connections/login.php(2): require_once('/public_html/user...') #2 {main}
The line causing the error (connection.php:28) is this one:
$pdo = new PDO("odbc:Driver={SQL Server}; Server={$servername}; Database={$dbname};", $username, $password);
I already tried using other driver names, such as "SQL Server Native Client", "FreeTDS", etc. But all returns the same error. Another thing is that the SQL Server isn't on the same server.
The solutions that I found on my research was telling me change the odbc.ini file and other files. But, I don't have access to those file on the server. Besides, on my local, I didn't change none of those files, just extended the modules to activate PDO and ODBC on the PHP.
Also, I already checked the phpInfo and the PDO and ODBC are enabled with "PDO Driver for ODBC (unixODBC)".
Anyone have experienced this kind of problem?

MS Access DB in php 64bit SQL state IM002 error

I'm trying to fetch data from access db in php. Code works fine for 32 bit php( I've tested in php version>5), but code generates error for 64bit php wamp.
Error Message: Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in
What I've tried : How can I correct this error: Data source name not found and no default driver specified
Code :
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$db", "","");
$tabs = odbc_tables($connection);
Is there any solution or I've to install 32 bit version?
Microsoft Access Driver (*.mdb)
refers to the older Access "Jet" driver which is installed as part of Windows itself but is only available to 32-bit applications. (There is no 64-bit version of Jet.)
You could download and install the 64-bit version of the newer Access Database Engine (a.k.a. "ACE", available here) and then use
Microsoft Access Driver (*.mdb, *.accdb)
as the driver name. (Assuming that the WAMP server does not already have a copy of Access 2007 or later installed on it.)

Categories