I have Microsoft Access Database (mdb file) with a table in it (we'll call that table A) that is linked to another Microsoft Access Database (we'll call that table B). I need to be able to update table A using php (which will in turn update table B, since A is linked to B). Please note that the table I'm linking to has a primary key named "Intersection" and it is set to Indexed: Yes (No duplicates).
If I use a simple odbc_connect and odbc_exec to run the following query:
$con= odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $user, $password)
$res = odbc_exec($con, "UPDATE tableA SET myfield=NULL WHERE myfield=2439;");
However, when I try this on a database with a linked table, I get the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] Operation must use an updateable query., SQL
state S1000 in SQLExecDirect in G:\web\libs\test.php on line 413
For some reason it seems that my database is not updateable even though it should be. It has a primary key defined and is a simple table (except for the fact that it's linked). Originally I was getting the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] 'H:\test\Database\test.mdb' 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 SQLExecDirect in G:\web\libs\test.php on line 413
But then I changed my linked table so instead of using drive letters to navigate to the linked table, I used the absolute \server\ path, which seemed to fix that problem, however not it is not able to be updated.
In case it helps, to create the Linked table, all I did was (Using MS Access 2010) I hit the "External Data" tab, then the "Access" (button), then I made sure to hit "Link to the source by creating a linked table" (option) and I selected the other database which contains the original table.
Is there some way to run an update on a linked access table using php?
Again, if you have a MS Access linked table that is linked to another table, and these tables have a primary key that is properly indexed. You CANNOT update the table using the following above PHP code (even though it works completely fine on an table which is not linked).
Please note, I have tested this with a fresh accdb database file as well, and if it is a linked table, it seems it will become read-only if you try to update the table using odbc_exec, however it does return data just fine, I just can't insert or update records.
Thank you.
[UPDATE]
Our server is running Windows Server 2003 with apache, and php. So I set up a Windows 7 machine with apache, and php, and it IS able to update a linked database without a problem, so I suspect my problem (since it's the only difference between the machines that could affect this), is that the Win2003 server is running odbc v3.5 whereas my win7 Machine is running odbc v6.1. I'm still looking into this further and will update this post if I find a solution to getting it working on our Windows Server 2003 machine.
Related
I have yii2 project and connected to ms sql server. I have added dll files necessary for connection to ms sql server and put them in xampp/php/ext and put them in php.ini. I'm using PHP 7.2
This is the dll files that I installed and set in my php.ini
extension=php_pdo_sqlsrv_71_ts_x64
extension=php_pdo_sqlsrv_71_ts_x86
extension=php_pdo_sqlsrv_72_ts_x64
extension=php_pdo_sqlsrv_72_ts_x86
extension=php_sqlsrv_71_ts_x64
extension=php_sqlsrv_71_ts_x86
extension=php_sqlsrv_72_ts_x64
extension=php_sqlsrv_72_ts_x86
After that I install odbc driver 11. I open yii2's default login page and input random username and password, then I got this error:
The table does not exist: {{%user}}
It's because I haven't executed the first migration yet, so user table has not been created yet. This means yii2 has successfully connected to ms sql server, right?
The problem is, when I tried the migration, I got this error:
Exception 'yii\db\Exception' with message 'could not find driver'
What could be the problem? Any help would be much appreciated.
I have linked SQL Server into Active Directory and am trying to use PHP to create an ODBC connection to pull in the data. I can read from Active Directory fine but when I try and update it using SQL UPDATE, I get this error
Msg 7390, Level 16, State 2, Line 1
The requested operation could not be performed because OLE DB provider "ADSDSOObject" for linked server "ADSI" does not support the required transaction interface.
I know I have to use PHP's LDAP functions but I am not sure how to rewrite the LDAP string to use in PHP. My best guess would be:
I tried (example string):
OU=staff,DC=example,DC=internal
but this doesn't work. My question is: assuming there is no way of updating Active Directory from my SQL view, how do I go about updating LDAP with PHP?
I want to transfer a system to the other server with the deterioration of the server that a certain system works.
After transferring a program file and a database to a new server, an error occurs.
■Error contents
Warning (2): pg_query() [function.pg-query]:
Query failed: ERROR: An input sentence structure of model integer is invalid: "\x3234"
LINE 1: ...Aro0"."model" = 'User' AND "Aro0"."foreign_key" = '\x3234' ...
^ [CORE\cake\libs\model\datasources\dbo\dbo_postgres.php, line 148]
※Original Message(in japanese) : Query failed: ERROR: 型integerの入力構文が無効です: "\x37"
For environment
(former)
PHP: 5.2.13
CakePHP: 1.2.7
Apache: 2.2.15
Postgre: 8.4.4-1
(newly)
PHP: 5.5.15
CakePHP: 1.2.7
Apache: 2.4.10
Postgre: 9.2.9.1
I copied a program file from an old server after installation of PHP and Apache and PostgreSQL.
※I changed the connection server to the new server in database.php
※I describe php.ini, httpd.conf to become the setting same as an old server
Login screen (index.php) coming to be displayed,
and inputting ID and a password, and running login processing, the errors occurred.
The real error is ""foreign_key" = '\x3234'" part
that only numerical value guesses character string called"'\x3234'" right in foreign_key.
Only the number to 2 figures is really registered with the item equal to foreign_key even if I confirm a database.
Foreign_key which the login user has is "24",
but seems to be treated in one of login processing as "'\x3234'".
After doing it I tryed to login in other login users,
9 ⇒ '\x39'
7 ⇒ '\x37'
23 ⇒ '\x3233'
24 ⇒ '\x3234'
The left is foreign_key, and the right is really used by SQL.
A head has "\x3", and there seems to be "3" before the second column when there are two columns.
Is there any differents for settings of PHP/CAKEPHP/APACHE/POSTGRESQL ?
I really don't know what causes this error.
CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]:
General error: 1 table 'YiiSession' already exists. The SQL statement executed was:
CREATE TABLE 'YiiSession' (
"id" CHAR(32) PRIMARY KEY,
"expire" integer,
"data" BLOB
)
Is it in the server or in yii..
but i guess it is in the yii part.
but what configurations did i miss?
i'm not really familiar with yii because im new to it.
any help please?
Thanks in advance
UPDATE: I check YiiSession in my database but it is not in there...
Delete the runtime folder.
Because runtime folder is used by the system for various tasks: session, logging etc.
It is also in the runtime folder that YiiSession table is created
In case anyone is still referencing this - the more complete answer is that Yii uses a SQLite3 database by default if you don't specify a connection string in your (CDbHttpSession) session config. This SQLite db is created in the runtime folder. (Which is why deleting the contents of the runtime folder works - you actually only need to delete the session-x.x.xx.db file.) If you want to use the same database you are using for your main connection, add:
'connectionID'=>'db',
to your session config. It's also recommended for production use you set autoCreateSessionTable to false, which will also prevent the error - you just need to make sure you deploy the SQLite db or set up the proper table in your main db. see here
By default, it will use an SQLite3 database named 'session-YiiVersion.db' under the application runtime directory. You can also specify connectionID so that it makes use of a DB application component to access database.
Because no one answer my question Codeigniter using ms access database , i make new question i not using codeigniter
if I using mdb from my computer it works but if i using mdb from another computer in my network
i got error this is my CODE
<?php
$connect = odbc_connect("testdb", "", "");
$query = "SELECT * FROM ACGroup";
$result = odbc_exec($connect, $query);
while(odbc_fetch_row($result)){
$name = odbc_result($result, 1);
echo("$name");
}
?>
i make odbc where the data its from another computer in my network
"testdb" are data sourcename and database \\ip\folder\testdb.mdb
and i got this error
Warning: odbc_connect() [function.odbc-connect]: SQL error: [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.,
SQL state S1000 in SQLConnect in D:\blabla\coba.php on line 3
I already try folder setting but it not work
The ODBC connection string you are using ("testdb") does not even specify a database driver, much less a database file. You will need to read up on the appropriate format for $dsn. (The php.net page even has a few examples for Access files.)
The problem possibly lies in the permissions your Apache user has on the mdb file.
Go to your mdb file, right-clik on the file -> Properties ->Security tab and see if your Apache user is on the User Groups that have access/control on the mdb file.
In order to see/change your Apache user, go to Control Panel-> Administrative Tools -> Services, right-click on Apache service -> Properties -> Logon tab. In the Log on as option, see if the user selected belongs to the User Groups that have access to mdb file. If not, create one and add it to the User Groups and then use it as the Apache account.