mdb tools/php

From: Date: Tue, 08 Apr 2003 10:05:59 +0000
Subject: mdb tools/php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-16647@lists.php.net to get a copy of this message
Good morning sirs ENVIRONMENT: Red Hat 8.0, Apache 1.3.27, OpenSSl 0.9.7, unixODBC 2.2.5, iSeriesODBC for AS400, php 4.3 All described above works very well; I can get data from AS400 db2 and put records into an html page. New Target: retrieving data from a Microsoft mdb file. I’ve successfully installed mdb tools. ../configure -–with-unixODBC –-enable.sql All application’s tools run OK I’ve added to /usr/keb/unixODBC/etc/odbc.ini (the application was build here) the following [MSAccess] Description = Microsoft Access Driver = MDBToolsODBC Database = /CUST97.MDB Servername = localhost UserName = Password = Port = 5432 I’ve added to /usr/keb/unixODBC/etc/odbcinst.ini (the application was build here) the following [MDBToolsODBC] Description = MDB Tools ODBC Driver Driver = /usr/local/lib/libmdbodbc.so.0 Setup = /usr/local/lib/libmdbodbc.so.0 FileUsage = 1 CPTimeout = CPReuse = I’ve created a sample file to test DSN: #!/usr/keb/php/bin/php <?php $query = "select * from AGENTI"; $dsn = "MSAccess"; $db = odbc_connect($dsn,"",""); $queryexe = odbc_do($db, $query); while(odbc_fetch_row($queryexe)) { $fld1 = odbc_result($queryexe, 1); $fld2 = odbc_result($queryexe, 2); $fld3 = odbc_result($queryexe, 3); print("$fld1"); print("$fld2"); print("$fld3\n"); } odbc_close($db); ?> I RUN THE SCRIPT FROM A COMMAND LINE ./php test.php ALSO HERE EVERYTHING WORKS VERY WELL !!! The script shows me on the screen data store in table named “agenti” NOW THE PROBLEM I’ve created a second file to display data from a browser: 1 <html> 2 <body> 3 <?php 4 $query = "select * from AGENTI"; 5 $dsn = "MSAccess"; 6 $db = odbc_connect($dsn,"",""); 7 $queryexe = odbc_do($db, $query); 8 while(odbc_fetch_row($queryexe)) { 9 $fld1 = odbc_result($queryexe, 1); 10 $fld2 = odbc_result($queryexe, 2); 11 $fld3 = odbc_result($queryexe, 3); 12 print("$fld1"); 13 print("$fld2"); 14 print("$fld3\n"); 15 } 16 ?> 17 </body> 18 </html> I put it inside /www/apache/htdocs/ and when I call it opening a browser I get: Warning: SQL error: [unixODBC]Could not find Database parameter, SQL state 08001 in SQLConnect in /usr/keb/apache/htdocs-portal/keb-php/test.php on line 6 Warning: odbc_do(): supplied argument is not a valid ODBC-Link resource in /usr/keb/apache/htdocs-portal/keb-php/test.php on line 7 Warning: odbc_fetch_row(): supplied argument is not a valid ODBC result resource in /usr/keb/apache/htdocs-portal/keb-php/test.php on line 8 HAVE SOMEONE IDEA OF WHY DSN RUNS WELL IF IT IS CALLED FROM A SCRIPT AND DON’T RUN IF CALLED FROM A HTML FILE ? Thanks !!! KEB ITALIA S.R.L. Toia Andrea Centro Elaborazione Dati Sistema Qualità

« previous php.mirrors (#16647) next »