我正在做这个项目,我需要连接到 Oracle 数据库。我正在使用最新版本的 WAMP 2.2,并且还激活了 PHP 扩展中与 Oracle 相关的所有扩展。我使用以下代码连接到 Oracle 数据库。
<?php
$dbHost = "192.168.0.205";
$dbHostPort="1523";
$dbServiceName = "orcl";
$usr = "system";
$pswd = "admin";
$dbConnStr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=".$dbHost.")(PORT=".$dbHostPort."))
(CONNECT_DATA=(SERVICE_NAME=".$dbServiceName.")))";
if(!$dbConn = oci_connect($usr,$pswd,'192.168.0.205:1158/em')){
$err = oci_error();
trigger_error('Could not establish a connection: ' . $err['message'], E_USER_ERROR);
}
else
{
echo "COnnected";
}
$strSQL = "SELECT SYSDATE FROM DUAL";
$stmt = oci_parse($dbConn,$strSQL);
if ( ! oci_execute($stmt) ){
$err = oci_error($stmt);
trigger_error('Query failed: ' . $err['message'], E_USER_ERROR);
};
while(oci_fetch($stmt)){
$rslt = oci_result($stmt, 1); print "<h3>query returned: ".$rslt."</h3>";
}
?>
请提出错误。提前致谢。