Note that there are some explanatory texts on larger screens.

plurals
  1. POunixODBC + mdbTools + PHP
    primarykey
    data
    text
    <p>I need to connect a PHP script in a LAMP (Linux Ubuntu 12.10, Apache 2, MySQL 5, PHP 5.3) server to an Access MDB database (version 2003).</p> <h2>1. unixODBC and Driver installation</h2> <p>The Ubuntu 12.10 comes with unixodbc 2.2.14 package (<a href="http://packages.ubuntu.com/quantal/unixodbc" rel="nofollow">http://packages.ubuntu.com/quantal/unixodbc</a>). The installation was easy: apt-get install unixodbc libmdbodbc1 php5-odbc. This way I've unixODBC with the mdbTools driver and the ODBC PHP capability.</p> <p>I've edited /etc/odbcinst.ini with the mdbtools driver:</p> <pre><code>[MDBToolsODBC] Description = MDBTools Driver Driver = libmdbodbc.so.1 </code></pre> <p>I've edited /etc/odbc.ini with the Access datasource:</p> <pre><code>[FormPulmo] Description = FormulariCDRPulmo Driver = MDBToolsODBC Servername = localhost Database = /mnt/svrfit/cdr/bd_pulmo_hardlink.mdb UserName = Password = port = 5432 </code></pre> <p>Finally I tested from shell and it worked:</p> <pre><code>&gt; isql -v formpulmo Connected! </code></pre> <h2>2. PHP connection</h2> <p>With PHP initialy all seems to work ok:</p> <pre><code>$link = odbc_connect ('formpulmo',"",""); $res = odbc_exec ($link,"SELECT * FROM exampleTable"); </code></pre> <p>The first problem was trying to access tables with spaces in their names. Example: "example Table". In Windows I've to put that between brackets ([example Table]) but it didn't worked. Finally I found the solution:</p> <pre><code>$res = odbc_exec ($link,"SELECT * FROM \"example Table\""); </code></pre> <p><b>Before this solutions all the browser response trying to do the odbc_exec were "Error 324 (net::ERR_EMPTY_RESPONSE)"</b></p> <h1>3. PHP problems !</h1> <p>But now I'm stuck with the UPDATE syntax. The normal query is:</p> <pre><code>$res = odbc_exec ($link,"UPDATE [Registre cancer de pulmo] SET CIP = 'example' WHERE CIP = 'example'"); </code></pre> <p>The browser response is: "Error 324 (net::ERR_EMPTY_RESPONSE)" (In Firefox: "The connection was reset").</p> <h2>3.1. Tried solutions</h2> <pre><code>UPDATE \"Registre cancer de pulmo\" SET CIP = 'example' WHERE CIP = 'example' UPDATE \"Registre cancer de pulmo\" SET \"CIP\" = 'example' WHERE \"CIP\" = 'example' UPDATE {Registre cancer de pulmo} SET {CIP} = 'example' WHERE {CIP} = 'example' </code></pre> <p>Connect with different cursors:</p> <pre><code>odbc_connect ($odbcFormPulmo,"","",SQL_CUR_USE_ODBC); odbc_connect($odbcFormPulmo,"","",SQL_CUR_USE_DRIVER); </code></pre> <p>I don't know what more I can try :-(</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload