我有以下脚本用于检查Linux中的PHP数据库连接:
<?php
$conn = oci_connect('proekt', 'proekt1', 'localhost:1521');
$stid = oci_parse($conn, "select 1+2 as sum from dual");
oci_execute($stid);
$row = oci_fetch_array($stid, OCI_BOTH);
echo $row[SUM];
?>
但它给了我这个警告:
Warning: oci_connect(): ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA in /var/www/test.php on line 2
我该如何解决?问题是什么?
答案 0 :(得分:3)
更改oci_connect()中的第三个参数帮助我:
$conn = oci_connect('proekt', 'proekt1', ' (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = proekt)
)
)');