Ubuntu 10.04 zend-server and informix connection - php

I have the issue, to get a PHP script connecting to an Informix DB. I thought installing the Zend-server community edition and in addition the pdo_informix extension. When I run the Zend-server admin in the browser, I see the pdo_informix extension marked as "green". Afterwards I've installed the Informix ClientSDK 3.70 on Ubuntu. I've set the $INFORMIXDIR environment variable into /etc/profile and into the PATH variable to the bin directory. The installation dir was /opt/IBM/informix . When I now try to write code in PHP like
try{
$db = new PDO("informix:host=xx.xx.com;database=xxx;server=xxx_net; protocol=onsoctcp;", databaseuser, databasepassword);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "test";
}catch (PDOException $e){
echo "<br/>Failed: ". $e->getMessage()."<br/>";
}
I've got the following error in the browser:
Failed: SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix]
[Informix ODBC Driver][Informix]Unspecified System Error = -23101.
If I'm trying to connect with the Server Studio on Ubuntu to the Informix DB it works well, but I guess they are using the JDBC driver.
If I go to the bin directory of my Informix clientsdk, there is an application called finderr. If I do a finderr -23101 I get the following output:
./finderr -23101
-23101 Unable to load locale categories.
So i thought that I have to set the DB_LOCALE, CLIENT_LOCALE environment variables... my server is using en_us.819 and my client is using en_us.utf8 .

Being unable to load locale categories normally means that either INFORMIXDIR is not set for the software trying to access the Informix locale data (which is found in $INFORMIXDIR/gls), or that the locale categories are unspecified or mis-specified. These are classically the environment variables CLIENT_LOCALE and DB_LOCALE, which have values such as 'en_us.8859-1' (the default) or 'es_es.utf8' (Spanish in Spain using UTF-8).
I would concentrate on ensuring that the browser has the environment set correctly. It may depend on how you launch it.
There are some other environment variables that could be used - DBLANG, LANG, and the LC_* set of names. However, they are unlikely to be needed if CLIENT_LOCALE and DB_LOCALE are set. With that said, I've recently found that with Informix 4GL (I4GL), some code written with Japanese characters in things like table names would not compile unless DBLANG was set as well as the *LOCALE variables. However, the LC* and LANG variables seemed to have minimal to no effect on the result.

You probably have to set LD_LIBRARY_PATH. I do it with:
export LD_LIBRARY_PATH=$INFORMIXDIR/lib/:$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql:
export PATH=$INFORMIXDIR/bin:$INFORMIXDIR/lib:/usr/local/bin:/usr/bin:/bin
If that will not help then you can try with unixODBC. It seems that PHP uses some kind of ODBC. In unixODBC online manuals there is article about connecting to Informix - read it. Use isql (interactive SQL) unixODBC tool to connect to configured ODBC database.
If isql cannot connect to database with the same error then you can use strace to see what library the ODBC driver cannot load.

Related

Access Sybase database from PHP

I have an application based on Sybase database. The application is running on a Windows Server 2003. I tried to fetch the database from the php and it is showing a number of dll files are missing including the php sybase extension. I checked the php extension dir and found that the file exists on the path where it is showing the errors.
Here i would like to mention that i installed xampp 1.8.0 on the windows server and enabled the sybase extension form the php.ini.
I used the following code to connect as mentioned on the php doc
<?php
$link = sybase_connect('SYBASE', '', '')
or die("Could not connect !");
echo "Connected successfully";
sybase_close($link);
?>
== Update ==
It was showing that the following dll files were missing and i downloaded and added them manually.
libcs.dll
libintl.dll
iconv.dll
Now i am getting the following error,
The procedure entry point iconv_open could not be located in the dynamic link library iconv.dll
This error is present from the beginning of enabling the Sybase PHP extension.
PHP Startup: unable to load dynamic library 'C:\xampp\php\ext\php_sybase_ct.dll' - the specified procedure could not be found
When I've seen unable to load dynamic library 'C:\xampp\php\ext\php_sybase_ct.dll' the issue has come down to a) having an old/outdated set of libs or b) using an application that references the 'old' Sybase lib names (with ASE 15, Sybase changed the names of their libs and some apps haven't picked up on this).
For the first issue the obvious (?) resolution would be to download the appropriate set of Sybase libs (which is going to depend on your application code/version as well as the ASE version). [Not enough info in your post to know if this explains your scenario.]
For the second issue there's a relatively easy solution (the following is based on a PHP app that has a Sybase-specific sub-directory containing the Sybase client-side libs):
in a Windows cmd window ..
source the *.bat file for your application [load your app's env]
cd to the Sybase sub-directory named ...\OCS*\scripts
run copylibs.bat
try starting your PHP app again and ...
if the issue is fixed then the php_sybase_ct.dll error message should go away

After snapshot boot : Informix Client -23101 / Oracle instant client -28759

Not to waste your time, I'll describe what I had && what I have now. My apps are written on php. They live on redhat6 server with nginx + apache web servers. We store data in MySQL DB, but we have lots of imports from Oracle and IBM Informix DB's, & mssql. For Oracle & Informix I have installed clients && compiled libraries pdo_oci.so & pdo_informix.so . For a few months they were working as expected.
But a week ago, admins made a snapshot of out virtual server, and reloaded it. Now only MySQL and mssql connectors work, and Oracle & IBM clients thows errors.
Oracle : -28759
Failed : SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-28759: failure to open file (/usr/local/src/php-5.3.3/ext/pdo_oci/oci_driver.c:579)/opt/project/www/test.php149
IBM Informix : -23101
Failed : SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23101./opt/project/www/test.php146
Well, as official documentations says, Informix error is connected with the lost env variables of DB_LOACALE & CLIENT_LOCALE...etc.
This is strange, because all this time I was using this string for my connections :
$dbh = new PDO ("informix:host=example.ru; database=some_db; server=db_net; CursorBehavior=0; DB_LOCALE=en_US.57372; CLIENT_LOCALE=en_US.57372;", "db_login", "pass");
I tried to set up this env variables for apache (httpd) , but this error still accures. Now I have this variables set after server reboot, but no success. May be I'am doing something wrong or at the wrong place or user name...
About Oracle , documentation says that it is connected with files loading:
And the web doc says that it is mostly ssl error and is connected with the trouble of the client, that can not find SSL Wallet files. I Have TCPS secure connection to Oracle DB with wallet, and I remember that it was a real trouble to make Instant client to look at the right place. More than that, I have client tracing enabled, but it is writing log only when I use sqlplus directly from terminal. When I run my php scripts, I got only errors and no log.
Questions:
How to enable Informix variables correctly, or how to resolve this
issue in different way.
How to enable "net tracing" for oracle, to
see what he is looking for?
How to store this variables for future
reboots/reloads/snapshots...etc. ?
People. Enable tracing of all what is possible and use "strace" command to check where programm is failing!!!
Thanks to Luís Marques! I found gls in my logs and tried to make link for it.. to real IBM/informix/gls... than another msg trouble acured.../ I made soft link from /usr/informix to my real /opt/IBM/informix and all connections successfully woke up!
Thank you man. You really helped me to finish this trouble. I post this as ansver but will accept yours as thanks to you! =)
This may be related to file / dir permissions rather than env variables.
The oracle error seems to indicated that it can no longer open/read the files it requires.
The informix -23101 error can also be caused by the driver being unable to read GLS files required for locale support.
Does the apache user have access to the Informix Client SDK directories and files?

How can I determine what drivers are available to use with odbc in php (on a linux system)?

In PHP scripts, it looks like this is how you connect to an odbc database:
$connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password);
The problem I'm having is that I don't know what to use for "Driver=". What I put in there is what was provided for another script I saw. In my script, all I do is try to connect using this line, but I get the following error:
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /srv/www/htdocs/site/test.php on line 8
From what I can tell, it looks like the driver I specified is incorrect. The database I am trying to connect to is an MSSQL database, and I only plan to query for information from it. Is there a way to list the database drivers I have available on my system? I've never had to install/configure any drivers like this before (I've never done anything like this; all php work I've done in the past has been with MySQL). Also, I don't want to compile other software onto my system (if possible); I would prefer to install all packages from repos.
You should have a file called odbcinst.ini (probably in /etc or /usr/local/etc but you can locate it with the command odbcinst -j). This file defines your ODBC drivers. Each driver is named within the [] in each section.
You might find Linux ODBC useful as it contains a thorough explanation of unixODBC, how it works and how to define data sources.
The question was how to find the list of ODBC drivers available. In the command line run:
odbcinst -q -d
This will list the drivers if you don't know already.

How to connect to Sybase via PHP

I'm trying to connect to a Sybase database with PHP5. I believe I've successfully compiled PHP with PDO_DBLIB, as phpinfo() lists dblib under PDO drivers, and freetds as the pdo_dblib flavour.
However, when I try to test a connection, I get an error reading:
'PDOException' with message 'could not find driver'
I'm trying to connect to a server on my LAN with this code:
$dbh = new PDO("sybase:host=192.168.1.xxx;dbname=[database-name]", '[user]', '[pass]');
Any suggestions would be greatly appreciated!
You should use dblib instead of sybase, like this:
$dbh = new PDO("dblib:host=192.168.1.xxx;dbname=[database-name]", '[user]', '[pass]');
PDO wouldn't work, or at least there is no PDO Sybase support for php. On Windows, you can use ODBC, and PDO_SQLSRV or PDO_ODBC, it might sound weird, but it should work.
Second option and I would recommend it, is to connect directly to Sybase (SqlAnywhere), but you need to install SQL Anywhere PHP Module
If you are using Ubuntu you can put the LD_LIBRARY_PATH inside envvars and it seems to read... still trying to find a way to get it to stick on RHEL based systems... Windows I am not too sure about I would hope you could set a system wide variable under
my computer -> properties -> advanced options
If are using RHEL based systems it might be better to include the:
export LD_LIBRARY_PATH=/path/to/library/ in the httpd restart script (check to see if it loads /etc/sysconfig/httpd and if so add the line in there - now restart apache and you should see some activity.

DSN-less ODBC Connection to iSeries

I'm running PHP 5.2.4 with ibm_db2 v1.8.0 on Ubuntu 8.04.1 Server. I am trying to hit an IBM iSeries running OS/400 v5R3 but I'm not sure at all how to actually connect without a DSN. I've looked at http://www.connectionstrings.com/ but none of the DB2 or AS/400 connection strings seem to work. All I end up with is:
[IBM][CLI Driver] SQL1013N The database alias name or database name "" could not be found. SQLSTATE=42705 SQLCODE=-1013
Here is my current DSN string:
DRIVER={iSeries Access ODBC Driver};SYSTEM=192.168.0.20;Uid=user;Pwd=password
I've also tried the 'IBM DB2 ODBC DRIVER' but get the same error as the string above.
Here is what I use within the .NET environment:
Provider=IBMDA400.DataSource.1;Data Source=xxx.xxx.xxx.xxx;Password=xxxxxxxxxx;User ID=xxxxxxxxxx;Initial Catalog=SERVERNAME
You might be missing the "Initial Catalog".
As it turns out, I had to use ODBC as there wasn't an easy way to access DBU from PHP without having to set up DB2-C and pipe everything through there.

Categories