Trying to Connect to Oracle Database with PHP 7.2 - php

This is the output from phpinfo()
im trying to establish an Database Connection to an Oracle Database. But i get the following issue:
Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in C:\xampp\htdocs\TanWLSI\Login.php on line 6
I have set the php.ini Extension for OCI:
extension=php_oci8_12c
This is the output from phpinfo()
Did i need an ORACLE_HOME Variable ?

Related

Invalid packet type error using php_mysql_xdevapi

I am trying to connect to mysql 8.0.15 using php_mysql_xdevapi but getting following errror.
Notice: mysql_xdevapi\getSession(): send of 5 bytes failed with errno=10053 An established connection was aborted by the software in your host machine.
Fatal error: Uncaught mysql_xdevapi\Exception: [2000][HY000] The server sent invalid packet type
I am using
Windows 10
MySQL 8.0.15
PHP 7.3.0
PECL Extension MySQL X DevAPI for PHP
Finally after 2 days of searching, I make php_mysql_xdevapi work on windows using wampserver.
Steps to make php_mysql_xdevapi work on windows 10, using wamp.
Install Pecl extension php_mysql_xdevapi.
Add the extension into the ini extension=php_mysql_xdevapi
Be default in wamp the XPlugin is disable enable it in my.ini
;Disabling X Plugin
;mysqlx=0
use this to connect to mysql using php_mysql_xdevapi
$session = mysql_xdevapi\getSession('mysqlx://root:123#localhost:33060?connect-timeout=5000&ssl-mode=disabled');
Now you can use this to further query in mysql document store.

"Warning: oci_connect(): OCIEnvNlsCreate() failed" and "Warning: oci_connect(): Error while trying to retrieve text for error ORA-01804"

I'm new to PHP and Oracle. I'm trying to make a connection between my application in PHP and an Oracle DataBase. I'm using:
Red Hat Enterprise Linux Server release 7.4 (Maipo)
PHP 5.4.16
Apache/2.4.6 (Red Hat Enterprise Linux)
In order to do that I installed Oracle Client and oci8, but I am having these:
Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_PATH includes the directory with Oracle Instant Client libraries in /var/www/html/TTS/Portal/Recursos/php/login/Login.php on line 7
Warning: oci_connect(): Error while trying to retrieve text for error ORA-01804 in /var/www/html/TTS/Portal/Recursos/php/login/Login.php on line 7
Line 7 has:
$Conexion=oci_connect('user', 'pass','Ipaddress/DBname');
I read that it could a problem with environment variables
I have in /root/.bash_profile, the following text:
export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG=American_America.UTF8
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
In /etc/sysconfig/httpd, I have:
LANG=C
ORACLE_HOME=/usr/lib/oracle/12.2/client64
LD_LIBRARY_PATH=$ORACLE_HOME/lib
NLS_LANG=American_America.UTF8
export ORACLE_HOME
export LD_LIBRARY_PATH
export NLS_LANG
phpinfo() shows me the following:
Apache environment and Environment
PHP variables and Oci8
I don't know how to fix the problems, I'd appreciate any help
Thanks

PHP on IIS doesn't load sqlsrv extension

I'm trying to put together a page that can submit data from a form to an MSSQL database via PHP. I've got PHP installed successfully (phpinfo() runs fine even on a remote computer) but it will not load the sqlsrv extension. I know that I'm editing the right php.ini file because I have another extension added (wincache) and it is loading fine, confirmed with both phpinfo() and get_loaded_extensions().
The logs aren't telling me anything. PHP Manager on IIS is telling me that the sqlsrv extension files are enabled. I've restarted the website, the server, and the computer, and nothing's working.
I'm using PHP 7.1.1 on a Windows 7 Ultimate machine. It's running in x64 mode, Non-Thread Safe. I've made sure that the extension files I enabled are the x64, non-thread-safe ones. I don't know what else to check or what more info I need to provide.
EDIT: I ran php-cgi.exe as this page suggested, and it came out with the error mesages:
[31-Mar-2017 22:38:12 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\iis express\PHP\v7.1\ext\php_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
in Unknown on line 0
[31-Mar-2017 22:38:17 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\iis express\PHP\v7.1\ext\php_pdo_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
in Unknown on line 0
Does this mean that the problem is in the extension DLLs themselves? How would I even go about fixing that?
EDIT 2: ImClarky nailed the problem in that I was apparently using a way outdated version of the extension. I've got it working, but now my authentication is failing for reasons I don't understand:
function connect_sql() {
/* Specify server and connection attributes */
$serverName = "(local)";
/* Get UID and PWD from app-specific files */
$uid = file_get_contents("C:\AppData\uid.txt");
$pwd = file_get_contents("C:\AppData\pwd.txt");
$connectionInfo = array("UID" => $uid,
"PWD" => $pwd,
"Database" => "database_name");
/* Connect using SQL Server Auth */
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false)
{
echo "Unable to connect.</br>";
//die(print_r(sqlsrv_errors(), true));
die(print_errors());
}
else {
echo "Connection Successful";
}
/* Free connection resources */
sqlsrv_close($conn);
}
I've double checked that I am using the correct username and password, and I even went in and created an entirely new login using the exact UID and password I'm trying. I still get the following error message every time:
Unable to connect.
SQLSTATE: 28000
code: 18456
message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'username'.
SQLSTATE: 28000
code: 18456
message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'username'.
Make sure you add .dll file for extension folder used by php.ini
Also chose correct driver of SQLSRv matched your running PHP
SQLSRv sqlsrv from official microsoft page

PHP 64 bit - Teradata ODBC driver failure - system error 126 'specified module cannot be found' -

I have installed PHP 5.6.30 64 bit on Windows Server 2012 along with Teradata ODBC driver.
Whenever I test the PHP connection I receive an error
Warning: odbc_connect(): SQL error: Specified driver could not be loaded due to system error 126: The specified module could not be found. (Teradata, C:\Program Files\Teradata\Client\15.00\ODBC Driver for Teradata nt-x8664\Lib\tdata32.dll)., SQL state IM003 in SQLConnect
EDIT: C:\Program Files\Teradata\Client\15.00\ODBC Driver for Teradata nt-x8664\Lib\tdata32.dll does definitely exist on that specific path. Also, using tdxodbc.exe to test the ODBC connection works normally using tdata32.dll, so it appears to be some issue with PHP.
I have installed Teradata ODBC via GSS > ICU > ODBC from the Utilities package based on a related thread however still experiencing the same error. I can make a successful 32-bit ODBC connection via SQL assistant. I have tried a DSN / DSN-less ODBC connection via PHP but same error occurs.
I have been unable to find any clear indication of what the issue is - any idea?

ci_connect(): OCIEnvNlsCreate() failed

I am using Laravel 5 with yajra/laravel-oci8 . Problem is that I am getting this error:
ErrorException in Oci8.php line 81:
oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries
I edited System Environment variables, activated OCI8 in php.ini and tried everything that I could find on Google but none of that worked...
EDIT: Added PHP Enviroments:
Does someone knows where's the problem?

Categories