I have XAMPP installed on my windows desktop and the odbc_connect with PHP works okay. I tried to run odbc_connect from Linux and got an error via the command line. I haven't tried the XAMPP install on Linux yet.
Ok, so here's my setup.Redhat ES 5Apache 2.2Php 5.14odbc 2.21Teradata driver 8.1....all rpms installed.when I run isql -v dbname dbuser dbpassword , I get this[ISQL]ERROR: Could not SQLConnectthrough php -> odbc_connect("edw_prod", "user", "password")I get this...popped into the apache error_logPHP Warning: odbc_connect() [ ]: SQL error: , SQL state 00000 in SQLConnect in (also the same for the user's .odbc.ini)[ODBC]InstallDir = /usr/odbcTrace = YesTraceDll = /usr/odbc/lib/odbctrac.soTraceFile = /edw/trace.logTraceAutoStop = 0[ODBC Data Sources]default = tdata.soedw_prod = tdata.so[edw_prod]Driver = /usr/odbc/drivers/tdata.soDescription = EDW PROD 5380DSNTraceEnable = YesDBCName = serverIPLastUser = Username = userPassword = Database = prodDateTimeFormat = AAASessionMode = ANSI[ODBC DRIVERS]Teradata = InstalledTrace = YesUsageCount = 4[Teradata]Driver = /usr/odbc/drivers/tdata.soUsageCount = 2APILevel = COREConnectFunctions = YYYDriverODBCVer = 3.51SQLLevel = 1HOME=/edwTWB_ROOT=/opt/teradata/client/tbuild/08.01.00.02TD_ICU_DATA=/opt/teradata/tdicu/libODBCINST=/etc/odbcinst.iniGuys, need your help ! been struggling in getting this working for over 3 days now.
no one have a setup like this at all???Linux/apache/php ?bunch of winblows users on here or what?
Hi, did you ever get the ODBC connection to Teradata from Apache and PHP to work? I am trying to do the same thing. I can use isql to connect to Teradata from the linux box and pull data, and I can run Teradata's 'adhoc' program and connection and pull data. But I cannot get php's odbc_connect() function to work. Looking at the detailed trace, it looks like somethign with the authentication, though I am properly passing username and password.
Thanks
Here is some information, how to build/install/configure and when Apache executes PHP as CGI binary :
---------------------------------------------------------------------------------------------------
It is important to build PHP against the DataDirect driver manager that is distributed with Teradata ODBC driver. For that reason make sure ODBC_HOME environment variable points to a correct folder. (showed below)
PHP configure looks header file odbc.h in the ODBC driver includes directory. So, make sure to create the header file with the file name odbc.h and add following lines in the file and save it:
#include <odbcinst.h>
#include <sql.h>
#include <sqlext.h>
(below steps used php ver 5.3.3)
> tar -xzf php-5.3.3.tar.gz
> cd php-5.3.3
> export ODBC_HOME=/opt/teradata/client/ODBC_32
> export CPPFLAGS="-I$ODBC_HOME/include"
> export CUSTOM_ODBC_LIBS="-L$ODBC_HOME/lib -lodbc -lodbcinst"
> ./configure --prefix=/usr/local/php --with-custom-odbc=$ODBC_HOME
> make <-- build
> make install <-- install
below are optional.
> php-cgi –v <-- to verify installation of PHP
> php-cgi –info <-- to see configuration information
Configuration of Apache server is controlled with httpd.conf file. Update the file to add support for PHP CGI scripts as follows:
Define a PHP CGI script directory alias, mapping an Apache document directory to a real directory where php-cgi binary is located. Inside <IfModule alias_module> section, add the following line to define a PHP CGI script directory alias:
> ScriptAlias /cgi-bin-php/ "/usr/local/php/bin/"
In the root of the document (outside of any section) add this access control section for this directory as:
<Directory "/usr/local/php/bin">
SetEnv ODBCINI "/ opt/teradata/client/ODBC_32/odbc.ini"
SetEnv ODBCINSTINI "/opt/teradata/client/ODBC_32/odbcinst.ini"
Options Indexes FollowSymlinks
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Inside <IfModule mime_module> section, add the following to define a new MIME type to support the .php file extension. Next add “Action” entry to tell Apache to serve the new MIME type with php-cgi binary located in the directory alias /cgi-bin-php/:
AddType application/x-httpd-php .php
Action application/x-httpd-php "/cgi-bin-php/php-cgi"
Note the definition of ODBCINI and ODBCINST environment variables. Those variables are passed into PHP process during request handling. Alternatively, those variables can be defined within PHP script itself:
<?php
putenv("ODBCINI=/opt/teradata/client/ODBC_32/odbc.ini");
putenv("ODBCINSTINI=/opt/teradata/client/ODBC_32/odbcinst.ini");
?>
Restart the server:
> /usr/local/apache2/bin/apachectl restart
thanks
Any suggestions for this error I am getting?
PHP Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/opt/teradata/client/ODBC_32/lib/tdata.so' : /opt/teradata/client/ODBC_32/lib/tdata.so: wrong ELF class: ELFCLASS32, SQL state 01000 in SQLConnect in /home/username/helloWorld.php on line 8
PHP Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in /home/username/helloWorld.php on line 10
It looks you odbc.ini file pointing to 32-bit ODBC Driver where as PHP is 64-bit. Update odbc.ini to point to 64-bit driver, usually it is /opt/teradata/client/ODBC_64/lib/tdata.so
Hi, I'm a complete dummy on php and making a connection to Teradata. I read carefully the above comments, but I cannot solve my problem. I hope someone can list up what is needed to make it work.
In short I want to make a odbc connection from php to a Teradata database. These are the product I installed:
TeraGSS_redhatlinux-i386-13.10.03.01-1.i386
TeraGSS_suselinux-x8664-13.10.03.01-1.x86_64
piom-13.10.00.05-1.noarch
cliv2-13.10.00.10-1.noarch
tdicu-13.10.00.02-1.noarch
tdodbc-13.10.00.07-1.noarch
unixODBC-2.2.14-11.el6.x86_64
unixODBC-2.2.14-11.el6.i686
Linux version 2.6.32-71.el6.x86_64 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) ) #1 SMP Wed Sep 1 01:33:01 EDT 2010
Webserver: Apache
The native odbc connection to the Teradata database, (the adhoc test) is working.
My php code is:
<?php
putenv("ODBCINI=/home/ID973285/.odbc.ini");
putenv("ODBCINSTINI=/home/ID973285/.odbcinst.ini");
$conn=odbc_connect("dwhd","id066955","xxxx");
$rs=odbc_exec($conn, "select * from dbc.dbcinfo;");
odbc_close($conn);
?>
Executing this small piece of code results in:
[id973285@el0861 html]$ php ws.php
odbcini =/home/ID973285/.odbc.ini
odbcinst =/home/ID973285/.odbcinst.ini
Segmentation fault (core dumped)
The content of my .odbc.ini file is:
[id973285@el0861 html]$ cat /home/ID973285/.odbc.ini
[ODBC]
InstallDir=/opt/teradata/client/ODBC_64
Trace=0
TraceDll=/opt/teradata/client/ODBC_64/lib/odbctrac.so
TraceFile=/usr/joe/odbcusr/trace.log
TraceAutoStop=0
[ODBC Data Sources]
default=tdata.so
testdsn=tdata.so
dwhd=tdata.so
[dwhd]
Driver=/opt/teradata/client/ODBC_64/lib/tdata.so
Description=Teradata running Teradata V1R5.2
#DBCName=208.199.59.208
DBCName=dwhdcop1
LastUser=
Username=
Password=
Database=
DefaultDatabase=
Any help is more than welcome.
Thanks!
Using php 5.2.9 on Fedora Linux 2.6.27 I am able to successfully use odbc_connect(), odbc_tables(), and odbc_columns(). So I can connect to the database, see its tables, and see the columns for any table. So far, so good.
However, when I use odbc_exec() to execute a simple SELECT statement, it gives "Memory fault" and drops me back to the shell. I even tried putting the odbc_exec() inside a try...catch block, but found this is not a catchable exception.
Has anyone else seen this behavior? Any suggestions?
Thanks in advance!
Has anyone successfully setup and run an Apache/PHP environment with the Teradata ODBC driver?I can get everything running, but odbc_connect() PHP calls result in segfaults in Apache. It's strange, because running php from the command line with the same php script works fine. Looking at the trace files, it looks like the authentication step is happening, and then poof.Any ideas of things to try?