原码。。<?php
putenv("ORACLE_SID=test");
putenv("ORACLE_HOME=/u04/app/oracle/product/8.1.7");
//putenv("NLS_LANG=AMERICAN_AMERICA.ZHS16GBK");
//putenv("LD_LIBRARY_PATH=/u04/app/oracle/product/8.1.7/lib");
//putenv("ORA_NLS33=/u04/app/oracle/product/8.1.7/ocommon/nls/admin/data");
echo "这不是乱码吧!";
//这个显示正常
if (empty($offset) || $offset < 0) {
$offset=0;
}
$limit = 3;
$db = "test";
$conn=ocilogon("test","test",$db);
if (!$conn) {
echo "<h1>ERROR - Could not connect to Oracle</h1>";
exit;
}
$sql = "Select * from cd";
$stmt = OCIParse($conn,$sql);
if(!$stmt) {
echo "<h1>ERROR - Could not parse SQL statement.</h1>";
exit;
}
OCIExecute($stmt);
$i=0;
$j=0;
while( OCIFetchInto($stmt, &$result_array) ) {
if ($i>=$offset) {
if ($j <$limit) {
for ($k=0; $k<=count($result_array); $k++) {
echo $result_array[$k]." ";
}
echo "
";
$j++;
}
}
$i++;
}
echo "
"; ?>
putenv("ORACLE_SID=test");
putenv("ORACLE_HOME=/u04/app/oracle/product/8.1.7");
//putenv("NLS_LANG=AMERICAN_AMERICA.ZHS16GBK");
//putenv("LD_LIBRARY_PATH=/u04/app/oracle/product/8.1.7/lib");
//putenv("ORA_NLS33=/u04/app/oracle/product/8.1.7/ocommon/nls/admin/data");
echo "这不是乱码吧!";
//这个显示正常
if (empty($offset) || $offset < 0) {
$offset=0;
}
$limit = 3;
$db = "test";
$conn=ocilogon("test","test",$db);
if (!$conn) {
echo "<h1>ERROR - Could not connect to Oracle</h1>";
exit;
}
$sql = "Select * from cd";
$stmt = OCIParse($conn,$sql);
if(!$stmt) {
echo "<h1>ERROR - Could not parse SQL statement.</h1>";
exit;
}
OCIExecute($stmt);
$i=0;
$j=0;
while( OCIFetchInto($stmt, &$result_array) ) {
if ($i>=$offset) {
if ($j <$limit) {
for ($k=0; $k<=count($result_array); $k++) {
echo $result_array[$k]." ";
}
echo "
";
$j++;
}
}
$i++;
}
echo "
"; ?>
页头这样写,你试试。<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>