Getting error in php ms access database connection - php

I want to go to build an application with PHP and with existing ms access. My xampp server running in local, but unfortunately my MS Access database located in other file server, previously it was running perfectly but suddenly it gives following error MSG
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] SQLDriverConnect: -1032 [Microsoft][ODBC Microsoft Access Driver]
The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user,
or you need permission to view its data.' in C:\xampp\htdocs\tbc\test.php:6 Stack trace: #0
C:\xampp\htdocs\tbc\test.php(6): PDO->__construct('odbc:DRIVER={Mi...') #1 {main} thrown in C:\xampp\htdocs\tbc\test.php on line 6
My actual code is:
$dbNameAccess ="//Fileserver/work/access/db.mdb";
if (!file_exists($dbNameAccess)) {
// die("Could not find database file.");
}
$db_na = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbNameAccess; Uid=; Pwd=;");

Related

How i can connect MongoDB online cloud in PHP

i want online connection with MongoDB cloud in PHP
same source file working properly when i run on localhost in my laptop with empty $server string while i use mongoDb server cloud then i face an error
<?php
session_start();
// $server="";
$server='mongodb+srv://mongo_user_1:<password>#mongodb01-dolny.mongodb.net/test?retryWrites=true&w=majority';
$mongo = new MongoClient($server);
$db=$mongo->blogPosting;
$admin_cl=$db->admin;
$category_cl=$db->category;
$blog_cl=$db->blog;
$contact_cl=$db->contact;
$blog_comment_cl=$db->blog_comment;
?>
Fatal error: Uncaught exception 'MongoConnectionException' with
message '- Found unknown connection string option 'retryWrites' with
value 'true'' in G:\xampp\htdocs\mongo_blog\mongoDb.php:5 Stack trace:
0 G:\xampp\htdocs\mongo_blog\mongoDb.php(5): MongoClient->__construct('mongodb+srv://m...') #1
G:\xampp\htdocs\mongo_blog\blog\index.php(1):
include('G:\xampp\htdocs...') #2 {main} thrown in
G:\xampp\htdocs\mongo_blog\mongoDb.php on line 5

PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]

I am trying to open an access file through php. The code i am using is this:
<?php
$connStr = 'odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};'
.'Dbq=C:\\file.accdb;';
$dbh = new PDO($connStr);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $dbh->prepare($sql);
$params = array();
$sth->execute($params);
?>
If i place the file in my IIS C drive, then php file opens just fine. If i try to place the file inside a network location (i have permissions in that network location) then i get the following error:
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] SQLDriverConnect: 63 [Microsoft][ODBC Microsoft Access
Driver]General error Unable to open registry key Temporary (volatile) Ace DSN
for process 0x16e0 Thread 0xd84 DBC 0x215b904
Jet'.' in C:\inetpub\wwwroot\app\update.php:56
Stack trace:
#0 C:\inetpub\wwwroot\teldir\update.php(56): PDO->__construct('odbc:Driver={Mi...')
#1 {main} thrown in C:\inetpub\wwwroot\app\update.php on line 56
In ODBC i have created a DSN and selected the file through network location.
Any ideas?
Thank you in advance

Connect to Access with PHP

I need to connect to an Access Database through PHP.
I've uncommented "extension=php_pdo_odbc.dll" in the php.ini file.
I've put the database in the same folder as the .php file I'm trying to connect with.
My code so far:
$dbName = "data.mdb";
if (!file_exists($dbName)) {
die("Could not find database file.");
}
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName");
My error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] SQLDriverConnect: -1811 [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.' in C:\xampp\htdocs\Test\index.php:40 Stack trace: #0
C:\xampp\htdocs\Access_Test\index.php(40): PDO->__construct('odbc:DRIVER={Mi...') #1 {main} thrown in C:\xampp\htdocs\LAWsites\Access_Test\index.php on line 40
Any ideas?
The Database Location parameter (DBQ) requires an absolute path to your database file:
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".realpath($dbName));
I was getting a similar error when the access database was located in the same folder.
SQLSTATE[HY000] SQLDriverConnect: -1044 [Microsoft][ODBC Microsoft Access Driver] Not a valid file name.
I put "./" in front of the filename and it worked.
$handler = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=./CIDB.MDB;");

Connect to Foxpro with PHP using OLE DB driver

I'm trying to connect to a Foxpro database using the OLE DB Driver
I downloaded the driver from http://www.microsoft.com/en-us/download/details.aspx?id=14839 and installed it then create a php script
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->Open("Provider=vfpoledb.1;Data Source=C:\Opera3\Comp_I.DBC;Collating Sequence=machine");
This gives me the following error
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Connection<br/><b>Description:</b> Provider cannot be found. It may not be properly installed.' in C:\inetpub\wwwroot\test1.php:4 Stack trace: #0 C:\inetpub\wwwroot\test1.php(4): com->Open('Provider=vfpole...') #1 {main} thrown in C:\inetpub\wwwroot\test1.php on line 4
Any help in getting this working would be much appreciated.
As requested
uninstalled and reinstalled from command line as administrator for all users and now it works –

PDO Informix SQLDriverConnect: -"917"

i have big problem while connection to a remote informix database server.
here's the code
$db = new PDO("informix:host=192.168.*.*; service=1565;
database=daten; server=name; protocol=onsoctcp;
EnableScrollableCursors=1", "informix", "info00");
print "Connection Established!\n\n";
echo "Table contents: $rows.\n";
I receive the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -917 [Informix][Informix ODBC Driver][Informix]Must close current database before using a new database.' in /var/www/informix.php:9 Stack trace: #0 /var/www/informix.php(9): PDO->__construct('informix:host=1...', 'informix', 'info00') #1 {main} thrown in /var/www/informix.php on line 9
How can I fix this?
I think you should also set the DB_LOCALE environment variable.
When the client application requests a connection, it sends information, including the DB_LOCALE to the database server.

Categories