无法连接PHP - Oracle 11g

时间:2014-12-17 03:29:13

标签: php oracle xampp oci8

只是尝试将PHP连接到远程Oracle 11g 并且仍然不好走。

这是我的phpinfo

PHPINFO

<?php
 $dbx = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.1.131)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESDB)))";

$dbz = "//192.168.1.131:1521/TESDB";


$db = oci_connect("user1", "user123", $dbz);

if (!$db) die("Error connecting to Oracle database: " . oci_error());

echo "Successfully connected to Oracle database!";

?>

我有2个变量$ dbx和$ dbz 尝试了两者,两者都失败了 即使oci_error没有给我一个消息错误 我错过了什么吗?

由于

1 个答案:

答案 0 :(得分:0)

该行中有错误:

$dbz = "//192.168.1.131:1521/TESDB"

缺少;,请尝试以下操作:

<?php
$dbz = "192.168.1.131:1521/TESDB";
$conn = oci_connect("user1", "user123", $dbz);
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
} else {
    echo "Successfully connected to Oracle database!";
}
?>