[英]how to use a user input defined in one html page in another php page to fetch data from oracle database
I have one php page which connects to the oracle database and fetches some data based on some user input. 我有一个php页面,它连接到oracle数据库并根据一些用户输入获取一些数据。 Here in this case Once the user will enter the user_id, and submit it, my code will fetch some more data (REQUEST_TIME,WORKFLOW_NAME,EVENT_MESSAGE) of that user. 在这种情况下,一旦用户输入user_id并提交,我的代码将获取该用户的更多数据(REQUEST_TIME,WORKFLOW_NAME,EVENT_MESSAGE)。 I am running below code and i am not sure if i am doing it correct. 我正在运行下面的代码,并且我不确定自己是否执行正确。 I am getting below error: 我得到以下错误:
Warning: oci_execute(): ORA-00904: "USER_ID": invalid identifier in D:\\SVN\\TOOLBOX_WEB\\WEBContent\\admin\\V2\\public\\ssn\\index2.php on line 36 警告:oci_execute():ORA-00904:“ USER_ID”:第36行的D:\\ SVN \\ TOOLBOX_WEB \\ WEBContent \\ admin \\ V2 \\ public \\ ssn \\ index2.php中的标识符无效
can someone please guide, how to proceed. 有人可以指导,如何进行。
This is my php page: 这是我的php页面:
<pre><?php
include('mypage.php');
class logAgent
{
const CONFIG_FILENAME = "data_config.ini";
private $_dbConn;
private $_config;
function __construct()
{
$this->_loadConfig();
$this->_dbConn = oci_connect($this->_config['db_usrnm'],
$this->_config['db_pwd'],
$this->_config['hostnm_sid']);
}
private function _loadConfig()
{
// Loads config
$path = dirname(__FILE__) . '/' . self::CONFIG_FILENAME;
$this->_config = parse_ini_file($path) ;
}
public function fetchLogs() {
$uid =$_POST["USER_ID"];
$sql = "SELECT REQUEST_TIME,WORKFLOW_NAME,EVENT_MESSAGE
FROM AUTH_LOGS WHERE USER_ID = '".$uid."'";
//Preparing an Oracle statement for execution
$statement = oci_parse($this->_dbConn, $sql);
//Executing statement
oci_execute($statement);
while (($row = oci_fetch_row($statement)) != false) {
foreach ($row as $item) {
echo $item . " ";
}
echo "\n";
}
}
}
?>
mypage.php mypage.php
<!DOCTYPE html> <html> <head> <title>User_Logs</title> </head> <body> <?php if ($_SERVER["REQUEST_METHOD"] == "POST"){ $uid =$_POST["USER_ID"]; $logAgent = new logAgent(); $logAgent->fetchLogs(); } ?> <form method="POST" id="form-add" action="index2.php"> USER_ID: <input type="text" name="USER_ID"/><br> <input type="submit" name="submit" value="Get_Logs"/> </form> </body> </html>
According to your error, oracle is complaining that it can't find the field USER_ID. 根据您的错误,oracle在抱怨找不到USER_ID字段。 Looking at your SELECT statement in the php file, oracle expects that field to be in your AUTH_LOGS table. 查看php文件中的SELECT语句,oracle希望该字段位于您的AUTH_LOGS表中。 Check to ensure that you've spelt the name of the field correctly or that the field exists in the table. 检查以确保您正确拼写了字段名称,或者该字段存在于表中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.