For a little while now, I've been looking how to try a connection to AS400 with Laravel 7.
I use this package : https://github.com/cooperl22/laravel-ibmi
I add laravel-ibmi to your composer.json file:
"require": {
"cooperl/laravel-ibmi": "^7.0"
}
Use composer to install this package.
$ composer update
Run on the command line from the root of my project:
$ php artisan vendor:publish
And set credentials in .env
DB_CONNECTION=ibmi
DB_HOST=********
DB_PORT=********
DB_DATABASE=********
DB_USERNAME=********
DB_PASSWORD=********
I try a connection with tinket but i have this message :
Psy Shell v0.10.4 (PHP 7.2.24-0ubuntu0.18.04.4 — cli) by Justin Hileman
>>> DB::connection();
PDOException with message 'could not find driver
I should set my credentials in app/config/db2.php, not in .env ?
UPDATE
I install the unixODBC
odbcinst -j
unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/za/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Download ibm_data_server_driver_for_odbc_cli_linux390x64_v11.5.tar.gz
tar -xavf ibm_data_server_driver_for_odbc_cli_linux390x64_v11.5.tar.gz
cd odbc_cli
sudo mkdir -p /opt/ibm/clidriver
sudo cp -r clidriver/* /opt/ibm/clidriver
Edit the odbcinst.ini
[Db2]
Description=Db2 Driver
Driver=/opt/ibm/clidriver/lib/libdb2o.so
fileusage=1
dontdlclose=1
Edit odbc.ini for the test
[sample]
Description = Test to DB2
Driver = Db2
but when i try i got this message
export DB2INSTANCE=db2inst1
isql -v sample db2inst1 ibmdb2
[01000][unixODBC][Driver Manager]Can't open lib '/opt/ibm/clidriver/lib/libdb2o.so' : file not found
[ISQL]ERROR: Could not SQLConnect
UPDATE 2
I go to https://www.ibm.com/support/pages/node/633843
Click Downloads for IBM i Access Client Solutions
When prompted, log in with my IBMid
Scroll down, and next to ACS Linux App Pkg, select Download now
After that i have installed ibm-iaccess-1.1.0.13-1.0.x86_64.rpm, i see it automatically adds the IBM i Access ODBC Driver to odbcinst.ini.
Edit odbc.ini for the test
[sample]
Description = Test to DB2
Driver = IBM i Access ODBC Driver
But it's the bug is repeated (Whereas /opt/ibm/iaccess/lib64/libcwbodbc.so exist).
isql -v sample
[01000][unixODBC][Driver Manager]Can't open lib '/opt/ibm/iaccess/lib64/libcwbodbc.so' : file not found
[ISQL]ERROR: Could not SQLConnect
UPDATE 3
I enter this command
ldd /opt/ibm/iaccess/lib64/libcwbodbc.so
linux-vdso.so.1 (0x00007ffe4830e000)
libodbcinst.so.2 => /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007f1fdc97e000)
libcwbcore.so => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1fdc5f5000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1fdc257000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1fdc03f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1fdbc4e000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f1fdba44000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1fdb825000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1fdce6c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1fdb621000)
I did that afterwards.
cp /opt/ibm/iaccess/lib64/libcwbcore.so /usr/lib/x86_64-linux-gnu/
isql -v sample
[S1000][unixODBC][IBM][Pilote ODBC System i Access]Le nom de syst�me requis pour la connexion est manquant.
[ISQL]ERROR: Could not SQLConnect
For PHP and Laravel it is wise to get the unixODBC working at the command line before trying to get it working with PHP. The reason is that troubleshooting is easier when you have fewer components to test. It also helps with separation of responsibilities.
The solution was to download and install
a suitable Db2-driver for ODBC/CLI on Linux specifically to work with i-series (AS/400) from IBM website at this link.
The other small footprint clidriver (supplied by IBM) cannot communicate with i-series unless you go via a Db2-connect gateway or have a Db2-connect licence (separate purchase). So it is usually more effective to use the IBM i access product instead. The clidriver works correctly without needing a license or Db2-connect, only when the target Db2-server runs on Linux or Unix variant or Microsoft Windows.
This IBM i access client product has a PDF document included "Installation and Usage Guide" which has helpful information, and several links to useful resources.
After installation, it is necessary to properly configure both the odbcjinst.ini (which details the driver) and the odbc.ini(which details the data soruces) (or .odbc.ini for user DSNs) for use with the driver supplied by the IBM i access client product.
Instructions for completing the odbcinst.ini and odbc.ini are available on the unixODBC website.
Test the connection to the i series with the isql tool, to verify that unixODBC is able to connect and use SQL queries.
The IBM i access product also has troubleshooting tools that includes cwbping and cwbtrc commands among others, which exercise the Db2-driver independently of unixODBC.
Once isql successfully connects to the i series database, you are now ready to configure PHP to use the driver in the normal way. You can then test with Laravel.
Remember to ensure that your linux shell sets the correct LANG environment variable to match your country and your character encoding before accessing the database (which require the relevant locale to be installed), otherwise codepage conversion may give unexpected results.
Related
I updated the language of my question, because the original question seemed to be worded in a confusing way (evident from downvotes and unhelpful comments). Hope this makes more sense.
Hi, I'm trying to upgrade the PHP version on a site, I followed this thread and it worked nicely on my development site - I basically changed all instance of PHP "7.1" in the trellis directory to "7.4", and required a PHP version of at least 7.4 in composer and ran composer update.
I happily pushed the update to the staging site, but when I attempted to provision the server with ansible-playbook server.yml -e env=staging, I received the following error:
TASK [Install Python 2.x] ************************************************************************************* ***********************************
System info:
Ansible 2.3.0.0; Linux
Trellis at "Update PHP from 7.1 to 7.4"
---------------------------------------------------
Shared connection to 107.170.41.149 closed.
fatal: [107.170.41.149]: FAILED! => {"changed": false, "failed": true, "rc": 100, "stderr": "Shared connection to 107.170.41.149 closed.\r\n", "stdout": "/usr/bin/python\r\nE: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).\r\n", "stdout_lines": ["/usr/bin/python", "E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."]}
Ansible seems to be getting stuck on the "Install Python 2." task. The staging server cannot be provisioned, and when I run php -v on the server it says it's running PHP 7.2.
How do I update PHP? I am avoiding doing it manually, because my gut's telling me there's a special roots way.
The server in question is Ubuntu 16.04 running PHP 7.2 (as mentioned above).
Below is the verbose output of the error from provisioning the staging server:
System info:
Ansible 2.3.0.0; Linux
Trellis at "Update PHP from 7.1 to 7.4"
---------------------------------------------------
OpenSSH_7.6p1 Ubuntu-4, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /home/jill/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 16490
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 100
Shared connection to 107.170.41.149 closed.
fatal: [107.170.41.149]: FAILED! => {
"changed": false,
"failed": true,
"rc": 100,
"stderr": "OpenSSH_7.6p1 Ubuntu-4, OpenSSL 1.0.2n 7 Dec 2017\r\ndebug1: Reading configuration data /home/jill/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 16490\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 100\r\nShared connection to 107.170.41.149 closed.\r\n",
"stdout": "/usr/bin/python\r\nE: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).\r\n",
"stdout_lines": [
"/usr/bin/python",
"E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."
]
}
This is neither a PHP composer nor a Python problem nor an Ansible problem. The underlying operating system (Ubuntu) has a problem with its apt libraries. The error comes from APT. Sadly you didn't tell us, what ansible module you use in the task named "Install Python 2.x".
Try 'apt-get -f install' with no packages
I think, some package installations hang on the system and need to be installed or configured. This may not have anything to do with your current job of upgrading PHP. Something went wrong in the past. APT will continue to stop operating til this issue is solved. Normally you would do it manually and have a look at the output of apt-get -f install to get an advice of what is the problem with that system. I think it will try to fix the issue automatically or throw an error what is the real issue (for example with two packages that cannot be installed at the same time or a file or directory that is missing or contains wrong values).
This is nothing "normal" which should happen all the time, when you update 100 hosts. This is very specific and part of the so called "configuration gap". Of course -if you dont want to login manually- you can ignore that error in your playbook task, but register the result, if the task failes, check, if the error messages in the registered var contains the above message in stderr and call a command module in your playbook. This would be a little bit of "self-healing".
Something like this
- package:
name: "..."
ignore_errors: true
register: installation
- shell: "apt -f install"
register: self_healing
when:
- "installation is failed"
- "'apt -f install' in installation.stderr"
- debug:
var: self_healing
when: "self_healing is defined"
I have a simple php script:
<?php
$db_user = 'myusername';
$db_pass = 'mypassword';
$db_sid = 'mysid';
$conn = oci_connect( $db_user, $db_pass, $db_sid );
?>
When I run it (from a browser or from the command line), I get the error:
Call to undefined function oci_connect
I'm using php 5.6.6 which came with php_oci8_12c.dll already there.
I have extension=php_oci8_12c.dll in my php.ini
I have installed instant client (12.1) - tried 32 bit version AND 64 bit version
I have ORACLE_HOME and TNS_ADMIN environment variables pointing at the instant client folder ( C:\instantclient_12_1 ).
I also have C:\instantclient_12_1 in my path
I have a tnsnames.ora in that same folder with this relevant entry in it:
MYSID =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost.net)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MYSERVICE)
)
)
I have also downloaded SQLDeveloper from http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
SQLDeveloper works, recognizes the above mentioned tnsnames.ora and connects and successfully runs a query on the same database that my php script is trying to access.
I have spent several hours over several days trying different things to no avail.
I'm using:
php 5.6.6
windows 8.1
IIS (so no answers involving apache please)
cmd (run as administrator)
Oracle Database 11g Enterprise Edition 11.2.0.3.0
Some other information that might prove useful:
I would ideally like to use oci 1.4.10 to match the production server, but not too worried about that for now.
pear install oci8-1.4.10.tgz
gives me this error:
The DSP oci8.dsp does not exist
I can't find any explanation on that error that means anything to me.
What am I missing - can anyone help me
EDIT:
I have tried the various suggestions in other posts on stackoverflow, namely:
extension=oci8.so with and without extension=php_oci8_12c.dll
I don't have the line extension=php_oracle.dll in my php.ini file
EDIT:
phpinfo tells me that I am using the correct php.ini file:
Loaded Configuration File => C:\php5.6.6\php.ini
This line from phpinfo might also be of use:
Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo"
EDIT:
It seems that dsp files are VC++ project files - I am now venturing on learning how to create a php extension, and hopefully when I've done that I'll have enough knowledge to compile the oci8 1.4.10 source code into a dll that works on windows 8 - unless somebody rescues me with the answer to this question - this looks like it is going to take me some time :-)
EDIT:
Adding display_startup_errors = On to php.ini tells me that the oci dll is not a valid Win32 application
Edit: Hmm. Trying this on Windows 8 appears to generate the same error as you specified. I'm currently investigating...
My mistake (I had enabled the wrong extension_dir line). It works in Win8 just as documented below.
The following steps should be all you need to get OCI working with PHP (I've just verified this on a freshly installed Windows 2008 R2 Standard x64 virtual machine):
Download and extract PHP (I used C:\php from php-5.6.7-nts-Win32-VC11-x86.zip).
Download and extract InstantClient (I used C:\instantclient_12_1 from instantclient-basic-nt-12.1.0.2.0.zip).
Add the above paths to the system path.
Copy c:\php\php.ini-production to c:\php\php.ini.
in php.ini:
enabled line extension_dir = "ext".
enabled line extension=php_oci8_12c.dll.
Install Microsoft Visual C++ 2010 Runtime (x86). This is needed for the OCI8 extension.
Install Microsoft Visual C++ 2012 Runtime (x86). This is needed for PHP.
At this point running php --ri oci8 in a command prompt shows me the following output:
C:\>php --ri oci8
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.0.9
Revision => $Id: f5a3ee1083d1ffa6adb5143efda6eafa210b8414 $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
Statistics =>
Active Persistent Connections => 0
Active Connections => 0
And checking for the oci_connect function:
C:\>php -r "var_dump(function_exists('oci_connect'));"
bool(true)
In addition to what was said to fix the problem, I would like to add the php CLI side of things, as some people need to run OCI-enabled applications in CLI mode. In my case, I had to copy an instance of oci.dll into the wamp/bin/php/php<version>/ folder for php --ri oci8 to show that oci8 was correctly loaded. That doesn't prove that other files were not needed to correctly run a full-fledged application (see my technical footnote).
Including the path to the instantclient 12 distribution wouldn't do it.
Technical notes:
My environment being: Windows 7 + WAMP3 (php 5.6.15, apache 2.4.17), I was, after a number of experiments, able to narrow down the minimal set of three files that needed to be copied to the bin directory (Apache's for non-cli apps) from the instantclient 12 distribution, to allow instantiate an Oracle adapter within Zend Framework, perform an SQL query and read the recordset.
This set is: oci.dll, oraociei12.dll and orans.dll.
In particular, copying just oci.dll wouldn't allow the application to work (unknow Exception raised)
All,
I am trying to install and get working the progress ODBC driver for Debian.
I have installed the progress driver no problem, however, when I try to connect in PHP using ODBC_Connect I get an error:
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/usr/dlc/odbc/lib/pgoe1022.so' : file not found, SQL state 01000 in SQLConnect
Next step was for me to see if the file existed and if that file had all of its dependencies.
So I issued the following command:
ldd /usr/dlc/odbc/lib/pgoe1022.so
And got the following:
linux-gate.so.1 => (0xb773e000)
libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb7505000)
libpgicu22.so => not found
libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xb7500000)
libstdc++-libc6.2-2.so.3 => not found
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb74da000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb7375000)
/lib/ld-linux.so.2 (0xb773f000)
Now I am stumped! I cannot get hold of the missing files.
Anyone able to assist at all please?
Regards
Col
It is always helpful to mention the versions of Progress, Linux, PHP and so forth that you are using.
Setting that aside for now. You say that you installed the ODBC driver "no problem". To confirm that you have done so and that the problem is external to the ODBC drivers you should first try a test connection with the supplied sqlexp utility.
From a Linux command shell start "proenv". This will properly set all the needed environment. Then run "sqlexp -u username -p password -db dbname -S port#"
That should get you a prompt where you can enter SQL queries etc.
If that works then you have all of the files needed from Progress' POV and the issue would be in your ODBC setup (odbc.ini). If it does not work then you likely have a Progress/OS release mismatch.
I am trying to connect to Oracle 11gR2 Xe on Ubuntu 13 server from another computer in the network, via PHP.
I am using installs and examples followed from oci_connect like here:
<?php
query_cities();
function query_cities() {
if {
$c = oci_connect("hr", "hr", "localhost:1521/XE");
;
} else {
echo "No connection"; }
?>
or another example like:
$c = oci_connect("hr", "hr", "192.168.1.33:1521/XE");
I have already enabled the remote connection in DB via SqlPlus
SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
and i have unlocked the user HR
SQL> ALTER USER hr ACCOUNT UNLOCK;
but I can only find some connection via IPv6 on the network from SQL Developer, like netstat:
tcp6 0 0 192.168.1.33:1521 192.168.1.2:57563 ESTABLISHED 14843/oracleXE
tcp6 0 0 192.168.1.33:1521 192.168.1.2:59314 ESTABLISHED 15665/oracleXE
not from my browser and they are not on tcp IPv4. The browser window remain white .. no reaction, unresponsive and no error message.
Should this be due to the TNSLR IP is active only on IPv6 or non of the oci_connect formulas are good enough or I am missing some other else?
I would appreciate any help on this issues
Alright, on the basis of received advice to seek the error in logs, I've found the message "*There is something wrong with your system - please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories*" and I decided to go through the sophisticated process of installing the Oracle InstantClient and reinstall OCI8 package, after the model from st-curriculum.oracle - with very small modifications, as follows:
Oracle 11g R2 XE database and Apache2 / PHP server have been apriori installed on Ubuntu 13.10 server and system prepared (with prereqiuzite, swap file, kernel parameters, memory leak error recover, libraries and chkconfig emulator), as described in many posts.
I stopped apache2 server
service apache2 stop
and started DRCP connection pooling as in st-curriculum.oracle.com
I created a user named PHPHOL (and alternate install Oracle's sample HR schema, if not already done at oracle install)
Next I downloaded the Basic and the SDK Instant Client packages from OTN: oracle.com/technetwork/database/features/instant-client/index-100365.html and unzipped the packages in $ORACLE_HOME, (/u01/app/oracle/product/11.2.0/xe)
Then I downloaded the OCI8 packeage from pecl.php.net/package/oci8 and installed in /opt/oci8 as instantclient
phpise
./configure --with-oci8=instantclient,/u01/app/oracle/product/11.2.0/xe/instantclient_11_2
make / make install
I set the oracle environment path as in oracle technote
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/xe/instantclient_11_2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH=/opt/oci8/modules
nano /etc/ld.so.conf.d/oracle.conf
and insert: /u01/app/oracle/product/11.2.0/xe/instantclient_11_2
nano /etc/ld.so.conf.d/oci8.conf
and insert: /opt/oci8/modules
nano /etc/ld.so.conf.d/shared.conf
and insert the installed shared extensions location: /usr/lib/php5/20121212
ldconfig
Next I edited the configuration file php.ini to add: extension=oci8.so, set the date.timezone directive and added also the OCI8 1.4 extension class: oci8.connection_class = MYPHPAPP (for the st-curriculum.oracle.com examples, see link above)
I made the link: $ORACLE_HOME/instantclient_11_2/libclntsh.so.11.1. to points to $ORACLE_HOME/instantclient_11_2/libclntsh.so
Restart Oracle database and Apache services on Ubuntu 13.10 server
/etc/init.d/oracle-xe force-reload
service apache2 start
I verified in phpinfo() the oci8 was enabled, and I made the connect.php file like:
$conn = oci_connect("hr", "hr", "localhost/xe");
or like the one from st-curriculum.oracle.com example.
From another computer on the same network I connected through a browser to oracle database on Ubuntu server and I've got
Connected to Oracle!
I hope this help
I am having serious problem connecting to external ORA DB 11g from local Zend server CE.
OCI8 is enabled and running version 1.4.6 (due to phpinfo()).
I have tried many connection options (listed below) with the same error returned:
oci_connect(): ORA-28547: connection to server failed, probable Oracle Net admin error
After googling for whole day I am only able to say that this error means that PHP was able to comunicate with the server but was unable to connect to a concrete service/database and that the error shouldn't come from PHP itself...
I have set environment variable TNS_ADMIN to c:\oracle_instantclient_11_2 where the file tnsnames.ora is located containing this connection description:
MYDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = X.X.X.X)(PORT = 1521))
)
(CONNECT_DATA = (SID = MYDB)(SERVER = DEDICATED))
)
Using this description like
(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))
I am able to connect to the server and the service/database with sqlplus console, so the connection is very right. I am also using the very same HOST, PORT and SID to connect to the server with Sqldeveloper tool. The problem is when connecting to the server within a PHP...
What have I tried so far:
oci_connect("user", "password", "X.X.X.X:1521", "AL32UTF8", 0);
oci_connect("user", "password", "MYDB", "AL32UTF8", 0);
oci_connect("user", "password", "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=X.X.X.X)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)))", "AL32UTF8", 0);
All of these oci_connect calls above return the same error mentioned.
I had also tried the ezconnect way for 11g as stated here - [//]host_name[:port][/service_name][:server_type][/instance_name]:
oci_connect("user", "password", "X.X.X.X:1521/MYDB", "AL32UTF8", 0);
but the problem is I do not know the service name, only the service ID (SID), thus the error returned is this:
oci_connect(): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
that says there is no service running with the service name provided (or that the ORA listener does not know of such service).
PHP version: 5.3.14
Appache v.: 2.2.22 (32bit) Zend
Zend server CE: 5.3.6
PHP info for OCI8:
OCI8 Support enabled
Version 1.4.6
Revision $Revision: 313688 $
Active Persistent Connections 0
Active Connections 0
Oracle Instant Client Version Unknown
Temporary Lob support enabled
Collections support enabled
Directive Local Value Master Value
oci8.connection_class no value no value
oci8.default_prefetch 100 100
oci8.events Off Off
oci8.max_persistent -1 -1
oci8.old_oci_close_semantics Off Off
oci8.persistent_timeout -1 -1
oci8.ping_interval 60 60
oci8.privileged_connect Off Off
oci8.statement_cache_size 20 20
Maybe the problem is that there is unknown version of Oracle instant client though it's path is set within both the TNS_ADMIN and PATH environment variables...
My question is: does anybody know of what have I done wrong? Am I missing something? I have googled for a whole day yesterday so probably (with 99% chance) any google links You would like to provide me with I have already seen and tried...
Though this question could be considered as an exact duplicate of this one - it has not been yet answered and I guess nobody will return back to that old question even if I post a comment I am having the connection problems too. Also keep in mind that in that similar question a different error is returned and asked about.
Due to several misconfigurations and 3 days lost while looking for a solution I moved to develop on Linux server and all of the problems are gone.
What I have found:
both php_oci8.dll and php_oci8_11g.dll are depending on the Oracle Instant Client libraries
these libraries does not contain oci_ functions (like oci_connect), only ociX functions (like ociLogon) which is strange...
though I am pretty sure I have downloaded Oracle Instant Client Basic and all of the extensions, I was not able to connect to another Oracle server due to unknown charset and the error was saying I am using only Lite instant client...
I tried both 64bit and 32bit instant client version at no avail
my Apache is 64bit, windows is 64bit, PHP is 32bit, remote Oracle server is 64bit, remote Linux server is 64bit...
tried many environment settings (ORA_HOME, TNS_ADMIN, adjusted PATH to look to instant client installation) at no avail
tried uninstalling local Oracle XE server due to possible environment settings interference at no avail
almost lost my head - at no avail...
So finaly on Linux server I have no problems connecting to remote Oracle server. Somewhere (while surfing over thousands of PHP-Oracle related pages) I have found an information that "one shouldn't develop PHP application connecting to Oracle server under windows" and should stick to UNIX system instead...
So anybody experiencing similar or same problems - be so kind and do not waste Your time, install a VirtualBox, run Linux on it and move forward!
to connect php to Oracle 11g version 11.2 you need to do following;
Step-1:
login to you db with sys as sysdba and execute following scripts.
**
execute dbms_connection_pool.start_pool();
execute dbms_connection_pool.restore_defaults();
**
Step-2:
in you PHP script
**
$conn = oci_connect("username", "password", "//hostname/servicename");
if (!$conn) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else {
print "Connected to Oracle!";
}
// Close the Oracle connection
oci_close($conn);
**
Note: i). Make sure PHP_OCI8 and PHP_OCI8_11g exertions are enabled
ii). Oracle 11 is case sensitive.
Best Regards
Yasir Hashmi
I have had the same issue and tried to connect from my local machine to a remote server.
after 2 weeks of tring I finally got it to work.
the solution is very simple but not documented in the PHP documentation
so let us take the sample PHP provided:
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
what they did not mention is that it points to the default port on the server.
if yours is set up to a different one you need to specify that.
see the new example below:
$conn = oci_connect('hr', 'welcome', 'localhost:1234/XE');
try that with your specified port.
Hope this helps
Just adding my two cents, as I Banged my head against the wall with this one... If all else fails, try this, Once you have downloaded the instant client, http://www.oracle.com/technetwork/topics/winsoft-085727.html, copy it's extracted contents to the apache/bin folder. It'll likely ask you to over-write the oci.dll. Do so, then restart apache/php. With luck this will fix the problem...
Good luck.
My solution on fedora 17:
1. yum install httpd httpd-devel.
2. yum install php php-mysql php-pear php-devel
3. Install oracle instantclient:
rpm -Uvh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
rpm -Uvh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
4. pecl install oci8
This gives:
**
downloading oci8-1.4.7.tgz ...
Starting to download oci8-1.4.7.tgz (Unknown size)
.....done: 168,584 bytes
10 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Please provide the path to the ORACLE_HOME directory.
Use 'instantclient,/path/to/instant/client/lib' if you're compiling
with Oracle Instant Client [autodetect] :'
**
Just press enter.
5. Enable the OCI8 extension by creating a file, oci8.ini for example, with the following line at /etc/php.d/:
extension=oci8.so
6. service httpd restart
For the record (PHP 8.0.12), you can also try:
In the Apache bin folder, copy inside the next files
📁 apache24
....📁 bin
....... 📃oraociei12.dll
....... 📃oci.dll
....... 📃oraons.dll
You can find those files in the Instant client folder and in the bin folder.
Then restart Apache and that is.
The instant client, apache version and PHP version must be or 32bits or 64bits.
You can also try to connect using ez-connection (if you want to avoid using the tnsnames).