PHP中的ORA-12504警告

时间:2013-01-08 06:04:06

标签: php linux oracle11g

我有以下脚本用于检查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

我该如何解决?问题是什么?

1 个答案:

答案 0 :(得分:3)

更改oci_connect()中的第三个参数帮助我:

$conn = oci_connect('proekt', 'proekt1', ' (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = proekt)
    )
  )');