简体   繁体   中英

Php Oracle connection: oci_connect(): ORA-24315: illegal attribute type error

I am trying to connect to Oracle database using php in windows.

$db = "BLM = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host)(PORT = 1521))
(CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = blm)
)
)";
$conn = oci_connect('blmuser', 'blmuser', $db);

if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
} 

I am getting the error oci_connect(): ORA-24315: illegal attribute type

I have tried setting the instant client path but to no avail.

phpinfo() 在此处输入图片说明

Solved the issue. I was trying with only php_oci8_11g.dll enabled in php.ini. Enabled php_oci8.dll extension and everything is working fine.

Just remove the BLM= as you need to give the description only as connection identifier. The former is needed, when you want to refer the alias name (BLM) as in tnsnames.ora instead of the full description.

$db = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host)(PORT = 1521))
(CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = blm)
)
)";

Notice how the marked extensions are ordered:

You should have extension=php_oci8.dll and then extension=php_oci8_11g.dll :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM