我在显示SQL查询结果时遇到问题(针对Oracle DB)。我的网页代码如下。我正在使用tnsnames并在oracle数据库服务器本身上运行Web服务器和页面。在sqlplus / sql developer中运行查询工作正常。
TNSNAMES:
testdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.101)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testdb)
)
)
页面显示2个变量,然后直接显示页脚。
如何显示返回的数据?有人可以帮帮我吗?
由于
<head>
<title>Reports</title>
<link href="Site.css" rel="stylesheet">
</head>
<body>
<?php include("Header.php"); ?>
<div id="main">
<h1>Report1</h1>
<h2>Report2</h2>
<p>Report3</p>
<?php
if (isset($_GET['var1'])) {
$var_storenr = $_GET['var1'];
}
if (isset($_GET['var2'])) {
$var_storearea = $_GET['var2'];
}
echo "<p>Var 1: " . $var_storenr . "</p>";
echo "<p>Var 2: " . $var_storearea . "</p>";
$db_user='testusr';
$db_pass='testusr';
$db_name='testdb';
$conn = oci_connect($db_user, $db_pass, $db_name);
$query = 'select id_store, store_des from np_stores where id_store in ('.$var_storenr.') and id_region = '.$var_storearea.';';
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, $query);
oci_execute($stid);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
<?php include("Footer.php"); ?>
</div>
</body>
答案 0 :(得分:0)
安装了x32客户端并且工作正常。
谢谢,